Welcome Guest, Not a member yet? Register   Sign In
Ion Auth - Lightweight Auth System based on Redux Auth 2

[eluser]ci_lover[/eluser]
A solution for retrieving online users:

Say I want to keep users logged in for 60 minutes (3600 secs):

1- In global config.php (config/config.php):
set the user session to last for 3600 secs:

$config['sess_expiration'] = 3600;

2- I then query the "users" table like this (using active record):

function get_online_users(){
$date = date("Y-m-d H:iConfused", time());
$users = $this->db
->where("TIMESTAMPDIFF(SECOND, FROM_UNIXTIME(last_login), '$date') < 3600")
->get('users');
return $users->result_array();
}

This will return the users who logged-in in the last hour, and so, are considered online, problem solved Smile

Hope this helps someone.


Messages In This Thread
Ion Auth - Lightweight Auth System based on Redux Auth 2 - by El Forum - 12-23-2010, 06:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB