Cyprian Gepfert
Cyprian Gepfert

Reputation: 383

How to list currently logged users in Kohana 3 Auth Module?

I dont use any tokens.

I know that it is possible to get currently used user like this:

$user = $this->get_user();

I need function to check if any user is logged :)

I want to do something like this:

//extending Model_User:
public function is_logged()
{
//return true or false
}

//using in controller

$user = ORM::factory('user');
$user->find($this->request->param('id'))

if($user->is_logged())
{
  //do_something();
}

Upvotes: 2

Views: 478

Answers (1)

biakaveron
biakaveron

Reputation: 5483

Auth module doesnt store any information about user sessions. You must create a table like (user_id, login_time, last_update_time, user_fingerprint). Where user_fingerprint is an unique token (for exampple, sha1(user_id + user_ip + user_agent)). Update this table after login/logout. last_update_time will store timestamp for last user activity (page load, ajax call etc), and it can be used for filtering old connections by timeout.

Upvotes: 1

Related Questions