php - How to store multiple params on Session -
i'm using this:
if(!empty($this->request->data['cd_pedido'])){ $this->set('filtrobusca',array('cd_pedido'=>$this->request->data['cd_pedido'])); }else if(!empty($sessaocdpedido)){ $this->set('filtrobusca',array('cd_pedido'=>$sessaocdpedido)); } if(!empty($this->request->data['cd_seq_pedido'])){ $this->set('filtrobusca',array('cd_seq_pedido'=>$this->request->data['cd_seq_pedido'])); }else if(!empty($sessaocdseqpedido)){ $this->set('filtrobusca',array('cd_seq_pedido'=>$sessaocdseqpedido)); }
and when : $this->session->read('filtrobusca')
or $_session['filtrobusca']
shows last checkbox selected. can tell me i'm doing wrong?
result $_session['filtrobusca']
array ( [cd_pedido] => 7 )
image of checkboxs:
you erasing array when setting in second 'if' condition. may consider using array buffer data want put in session, put @ once :
$filtrobusca = array(); if(!empty($this->request->data['cd_pedido'])){ $filtrobusca['cd_pedido'] = $this->request->data['cd_pedido']; }else if(!empty($sessaocdpedido)){ $filtrobusca['cd_pedido'] = sessaocdpedido; } //do same thing other 1
then put $filtrobusca
in session :
$this->set('filtrobusca',$filtrobusca);
Comments
Post a Comment