Welcome Guest, Not a member yet? Register   Sign In
How can I get session at multiple controllers
#1

Hi,
I set SESSION at Login.php controller, And I want get SESSION at other controllers,
But at other controllers, I get SESSION have `__ci_last_regenerate: 1552555932` only, No information I have stored in it.
What can I do something get the SESSION?
Thanks!

This is my Login.php controller

PHP Code:
class Account extends CI_Controller
 
{
 
 public function __construct()
 
 {
 
  parent::__construct();
 
  $this->load->model('Account_model');
 
  $this->load->library('session');
 
 }


 
 public function login()
 
 {
 
  $username $this->input->post('username');
 
  $password $this->input->post('password');

 
  // run login model,return array or FALSE
 
  $query $this->Account_model->login($username$password);

 
  if ($query) {
 
   // set SESSION
 
   // $query is array, like this :{'username'=>"bob",'level'=>2}
 
   $this->session->set_userdata($query);
 
   //do something...
 
  }
 
 }


And this controllers, I want use SESSION, but faile

PHP Code:
class Number_record extends CI_Controller
{
 public function 
__construct()
 {
 
 parent::__construct();
 
 $this->load->model('Number_record_model''NRM');
 
 $this->load->library('session');
 }

 public function 
add_num()
 {
 
 // I want get SESSION at this
 
 // But only get this :__ci_last_regenerate: 1552555932
 
 $_SESSION;
 
 $this->session->userdata()
 }

Reply


Messages In This Thread
How can I get session at multiple controllers - by nuonuonuo - 03-15-2019, 07:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB