Reputation: 4408
I have hard time with kohana sessions, i would like to store my sessions data in database i've already created default sessions
table, and i have this config file in
\application\config\session.php
And here is config content: http://pastebin.com/MqqQpH5W
Also my login works just fine, i've tried var_dump(Auth::instance())
and i see some stuff like { ["_session":protected]=> object(Session_Native)#20
so i guess my session does get started, but i'm quite lost on how do i set my session id to the database or some other stuff?
I guess i could just make a normal query for that, but i think there has to be better way to do it.
And btw my main goal is to make list of online users, and i see that i have in table row with name last_active
, so my guess is that something should update that table automaticaly, right?
EDIT So after some googling and search in various files i found out that it loads native
session type from config file in application/auth
, so i've tried to change it to database
and now it keeps putting session data in my database every time i refresh page, and login doesn't work anymore, any sugguestions?
Upvotes: 1
Views: 2483
Reputation: 721
In Kohana 3.2 you do it like this:
Put this in your bootstrap.php file:
Session::$default = 'database';
And also make sure your cookie configuration is correct. Put this in your bootstrap.php file also
Kohana_Cookie::$salt = md5('secret');
Kohana_Cookie::$expiration = 1209600; // 14 days
Kohana_Cookie::$domain = '.yourdomain.com';
Where .yourdomain.com will be your host name, make sure you put a dot (.) before it so it will include sub-domains too.
Upvotes: 1