Codeigniter Session Data not available in other pages after login
Posted
by jswat
on Stack Overflow
See other posts from Stack Overflow
or by jswat
Published on 2010-03-15T17:28:55Z
Indexed on
2010/03/15
17:29 UTC
Read the original article
Hit count: 259
So, I have set up a login page that verifies the user's credentials, and then sets codeigniter session data 'email' and 'is_logged_in' and a few other items. The first page after the login, the data is accessible. After that page, I can no longer access the session data. In fact, if I try reloading that first page, the session data is gone.
I have tried storing it in the database, storing it unencrypted (bad idea I know, but it was for troubleshooting), and storing it encrypted. I have autoloaded the session library in config.php.
Here's an example of the code I'm using to set the session data:
$data = array(
'email' => $this->input->post('username'),
'is_logged_in' => true
);
$this->session->set_userdata($data);
And to retrieve it, I'm using :
$this->session->userdata('email');
Or
$this->session->userdata('is_logged_in');
I've done lots of work with PHP and cookies, and sessions before, but this is my first project with Codeigniter and I'm perplexed.
Could it have something to do with directory issues? I have the login page and process controlled by a 'login' controller, and then it redirects to a 'site' controller.
Thanks for your help, and please let me know if I need to clarify anything.
© Stack Overflow or respective owner