Skip to content
This repository has been archived by the owner on Jan 9, 2018. It is now read-only.

Commit

Permalink
implemented user 'last login' date and time
Browse files Browse the repository at this point in the history
  • Loading branch information
vimishor committed Aug 26, 2012
1 parent 352bd6e commit 82e0857
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion www/app/libraries/Regnick_auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,44 @@ public function user_login($identity, $password, $remember)
return false;
}

$userID = $this->ci->user_model->getRow($identity, 'ID');

// register session
$session_data = array(
'identity' => $identity,
'email' => $this->ci->user_model->getRow($identity, 'email'),
'user_id' => $this->ci->user_model->getRow($identity, 'ID'),
'user_id' => $userID,
'user_flags' => $this->ci->user_model->getRow($identity, 'account_flags'),
);
$this->ci->session->set_userdata($session_data);

// update last login
$this->set_last_login($userID);

notify($this->ci->lang->line('login_successful'), 'success');

$this->ci->benchmark->mark('user_login_end');

return true;
}

/**
* Update last login time
*
* @access public
* @param int $userID User ID
* @return bool
*/
public function set_last_login($userID)
{
$data = array(
'last_login' => time()
);
$this->ci->db->where('ID', $userID);

return $this->ci->db->update('users', $data);
}

/**
* Is user logged in ?
*
Expand Down

0 comments on commit 82e0857

Please sign in to comment.