Welcome Guest, Not a member yet? Register   Sign In
Session been destroyed
#1

[eluser]Gerep[/eluser]
I'm making a login with permissions.

I have three session variables:

Code:
$this->session->set_userdata('user', $rs);
$this->session->set_userdata('views', $views);
$this->session->set_userdata('permissions', $permissions);
Those arrays are necessary so I can say if user X can access the screen Y.

My login controller if checking for the user info, add it to the session user, after that I check for this user permissions and add them to the session permissions, load all views and add them to views session.

Right after that I redirect the user to another controller: redirect('home', 'refresh'), this home controller extends MY_Controller

Here it is:

Code:
class MY_Controller extends CI_Controller {

    public $_template;

    public function __construct() {
        parent::__construct();

        $this->load->library('template');
        $this->_template = new Template();

        if( ! $this->session->userdata('user'))
            redirect('login','refresh');
    }
}
On the IF my sessions doesn't exist anymore. The session library is autoloaded.

The Home Controller:

Code:
class Home extends MY_Controller {

    private $_view = 'home';

    public function __construct() {
        parent::__construct();
    }

    public function index() {
        $this->_template->build($this->_view);
    }

}
What is happening with my sessions?

Thanks.
#2

[eluser]Akinzekeel[/eluser]
Is there a chance you're putting some special characters (like ä ö ü) into your session userdata? I think that will make the unserialize function fail and then create a new session (unless these characters are properly encoded of course).

There should also be something in your error logs like "Session data did not match what was expected." if this is your problem.




Theme © iAndrew 2016 - Forum software by © MyBB