Linas
Linas

Reputation: 4408

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',

Upvotes: 1

Views: 591

Answers (3)

Webmezha
Webmezha

Reputation: 117

1) All the errors occuring while writing a session are logged, but not displayed.
2) In Kohana 3 you need to specify Cookie::$salt in order to use any sessions (native as well).

(search of these two facts was quite a puzzle for me while upgrading from Kohana 2)

Upvotes: 0

Azri Jamil
Azri Jamil

Reputation: 2404

Try to add this in 'bootstrap.php'

Cookie::$salt = '021004042012';

The string are random key.

Upvotes: 0

feketegy
feketegy

Reputation: 721

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.

Upvotes: 0

Related Questions