Kohana 3.2 - Database Session losing data on new Page Request
        Posted  
        
            by 
                reado
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by reado
        
        
        
        Published on 2012-03-18T05:07:50Z
        Indexed on 
            2012/03/20
            23:29 UTC
        
        
        Read the original article
        Hit count: 296
        
I've setup my dev Kohana server to use an encrypted database as the default Session type. I'm also using this in combination with Auth to implement user authentication.
Right now my user's are able to authenticate correctly and the authentication keys are being stored in the session. I'm also storing additional data like the user's firstname and businessname during the login procedure.
When my login function is ready to redirect the user to the user dashboard, I'm able to see all the data correctly when I do $session::instance()->as_array(); (Array ( [auth_user] => NRyk6lA8 [businessname] => Dudetown [firstname] => Matt ))
As soon as I redirect the user to another page, $session::instance()->as_array(); is empty.
By dumping out the Session::instance() object, I can see that the Session id's are still the same.
When I look at my database table though, i dont see any session records being saved and my session table is empty.
My bootstrap.php contains:
Session::$default = 'database';
Cookie::$salt = 'asdfasdf';
Cookie::$expiration = 1209600;
Cookie::$domain = FALSE;
and my session.php config file looks like:
return array(
    'database' => array(
        'name' => 'auth_user',
        'encrypted' => TRUE,
        'lifetime' => 24 * 3600,
        'group' => 'default',
        'table' => 'sessions',
        'columns' => array(
            'session_id' => 'session_id',
            'last_active' => 'last_active',
            'contents' => 'contents'
        ),
        'gc' => 500,        
    ),
);
I've looked high and low for an answer.. if anyone has any suggestions, i'm all ears!
Thanks!
© Stack Overflow or respective owner