本文整理匯總了PHP中UserSession::val方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserSession::val方法的具體用法?PHP UserSession::val怎麽用?PHP UserSession::val使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserSession
的用法示例。
在下文中一共展示了UserSession::val方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: login
public function login($loginoremail, $password)
{
if (isset($_COOKIE[$this->cookie_name])) {
$this->logout();
}
$user = new User($this->db);
$user->loadByLoginOrEmail($loginoremail);
if (isset($user) && $user->is_loaded) {
if ($user->val('user_failed_attempts') > $this::$max_attempts) {
$messages[] = t('Max. number of login attempts exceeded. Please ask for new password.');
}
if (Authentication::verifyPassword($password, $user->val('user_password_hash'))) {
// success - create new session
$this->user = $user;
$this->updateLastAccess();
$token = $this->generateToken();
$token_hash = Authentication::hashPassword($token);
$expires = time() + Authentication::$session_expire;
$session = new UserSession($this->db);
$session->data['user_session_token_hash'] = $token_hash;
$session->data['user_session_user_id'] = $this->user->val('user_id');
$session->data['user_session_expires'] = SqlQuery::mysqlTimestamp($expires);
$session->save();
setcookie($this->cookie_name, $session->val('user_session_id') . "-" . $token, $expires, '/', false, false);
$this->session = $session;
} else {
$user->data['user_failed_attempts'] += 1;
$user->save();
}
}
}