예제 #1
0
 function check_remember_me()
 {
     $CI =& get_instance();
     $remember_me = $CI->input->cookie('remember_me');
     if ($remember_me !== FALSE) {
         $remember_me = @unserialize($remember_me);
         // Insure we have all the data we need
         if (!isset($remember_me['email']) || !isset($remember_me['token'])) {
             return FALSE;
         }
         // Database query to lookup email and password
         $User = new Users_model();
         $User->where("email", $remember_me['email'])->get();
         // If user found validate token and login
         if ($User->exists() && $remember_me['token'] == md5($User->last_login . $CI->config->item('encryption_key') . $User->password)) {
             if (!$User->enabled || $CI->settings->users_module->email_activation && !$User->activated) {
                 return FALSE;
             }
             $User->last_login = date("Y-m-d H:i:s");
             $User->create_session();
             $User->save();
             $this->set_remember_me($User);
             return TRUE;
         }
     }
     return FALSE;
 }