kohanakohana-3kohana-db

Kohana session keeps generating


I'm trying to set up my sessions so it would be stored in database, now it does just that but every time i try to login i keeps generating new session id and inserting new record, and the bigest problem that after i changed my session driver from native to database my login doesn't work, well it logins user but just after page refresh it's loged out, here ir my config:

return array(
    'native' => array(
        'name' => 'session_native',
        'lifetime' => 43200,
    ),
    'cookie' => array(
        'name' => 'session_cookie',
        'encrypted' => TRUE,
        'lifetime' => 43200,
    ),
    'database' => array(
        'name' => 'session_database',
        'encrypted' => TRUE,
        'lifetime' => 43200,
        'group' => 'default',
        'table' => 'sessions',
        'columns' => array(
            'session_id'  => 'session_id',
            'last_active' => 'last_active',
            'contents'    => 'contents'
        ),
        'gc' => 500,
    ),
);

and i've changed this line in my auth config from:

'session_type' => Session::$default,

To:

'session_type' => 'database',

Solution

  • You also need to setup your cookie config.

    Make sure your cookie domain is correct, it's probably the cause of throwing you out after login.