Welcome Guest, Not a member yet? Register   Sign In
SESSION:Find current active users in my app???
#9

[eluser]mindprojects[/eluser]
Thanks Lorren you gave me the right clue.
Now i've created a session variable in my login system for a more strict autentication.
Every time a user logs in i generate a unique token:


Code:
$uniquid =  md5(uniqid(rand(), true));

$this->update_user($user_id,array('bk01_uniquid' => $uniquid));
        
$this->session->set_userdata(array('uniquid' => $uniquid));



Then i've created this function to check if the user is logged into my auth library:

Code:
function is_logged()
{
   if($this->CI->session)
   {

       $logged = $this->CI->session->userdata('is_logged');
       $user_id = $this->CI->session->userdata('user_id');

       if ($logged == 1 && $user_id)
       {
            $is_logged = TRUE;
           //check if the auth strict config variable is TRUE
            if($this->CI->config->item('strict_auth'))
            {
               $uniquid = $this->CI->session->userdata('uniquid');
               //getting user data
               $query = $this->CI->user_mdl->get_user(array('bk01_user_id' => $user_id ));
               $is_logged =  ($query->row()->bk01_uniquid == $uniquid) ? TRUE : FALSE;
            }
        return $is_logged;

       }
   }
   return FALSE;
}


This is very useful if you also want to avoid multiple logins with the same credentials.

Thanks again.
Marco


Messages In This Thread
SESSION:Find current active users in my app??? - by El Forum - 10-12-2009, 09:13 AM
SESSION:Find current active users in my app??? - by El Forum - 10-12-2009, 11:51 AM
SESSION:Find current active users in my app??? - by El Forum - 10-13-2009, 12:46 AM
SESSION:Find current active users in my app??? - by El Forum - 10-13-2009, 12:47 AM
SESSION:Find current active users in my app??? - by El Forum - 10-13-2009, 09:00 AM
SESSION:Find current active users in my app??? - by El Forum - 10-13-2009, 01:31 PM
SESSION:Find current active users in my app??? - by El Forum - 10-14-2009, 01:26 AM
SESSION:Find current active users in my app??? - by El Forum - 10-14-2009, 11:46 AM
SESSION:Find current active users in my app??? - by El Forum - 10-15-2009, 01:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB