3
I have this normal Septssion:
foreach ($nofeatured_prods as $k) {
$_SESSION['itens'][$k->id] = $k;
}
How do I assign equally, however, in codeigniter?
3
I have this normal Septssion:
foreach ($nofeatured_prods as $k) {
$_SESSION['itens'][$k->id] = $k;
}
How do I assign equally, however, in codeigniter?
4
Use the method set_userdata() of the IC session library
To assign do:
$var = array('nome' => 'teste');
$this->session->set_userdata($var);
Or else:
$this->session->set_userdata('chave', 'valor');
To recover do:
$this->session->userdata('nome');
Loading
To load this library there are two ways, the first is to call it just where it will be used or by demand and the second let the framework already load it in all requests automatically.
First form:
$this->load->library('session');
Second form:
In the config/autoload.php file look for $autoload['libraries']
and add the element in this array session
.
$autoload['libraries'] = array('session', 'database');
Browser other questions tagged php codeigniter
You are not signed in. Login or sign up in order to post.
In this case @rray would be $this->Session->set_userdata($k, ???);
– Sr. André Baill
I need to set all the products that were listed through this array(), in this case, the $_SESSION worked, but in CI it doesn’t work. Because it’s not native to her, it has to be for $this->Session
– Sr. André Baill
@Andrébaill
$k
is name you will fetch the second argument is value. Error occurred?– rray
@Andrébaill I would do so to save an array in session
$this->session->set_userdata('produtos', $arr);
– rray
Yes, in this case I did: $this->Session->set_userdata('items', $nofeatured_prods);
– Sr. André Baill