简体   繁体   中英

Session return an empty response in other functions using Codeigniter 3.1

This code is working fine only in this function but when i get session in other functions then it return an empty response.

$id = '123'; 
$this->session->set_userdata('id','$id');
$get_id = $this->session->userdata('id');
print_r($get_id);

Get data in other function like.

 $get_id = $this->session->userdata('id');
 print_r($get_id);

which is return an empty response.

If anyone has any suggestions it would be very much apppreciated!

Thank you

Nearly, try this.

$id = array( '123' ); <-------
$this->session->set_userdata( 'id', $id ); <--------
$get_id = $this->session->userdata('id');
print_r($get_id);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM