本文整理匯總了PHP中App\Model\User::logout方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::logout方法的具體用法?PHP User::logout怎麽用?PHP User::logout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類App\Model\User
的用法示例。
在下文中一共展示了User::logout方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: check
/**
* Check for the user session
*
* @param Application $application
* @return void
*/
public static function check(Application $application)
{
$sess = $application->getService('session');
$action = $application->router()->getRouteMatch()->getAction();
if (isset($sess->user) && isset($sess->user->sess_id) && !isset(Table\UserSessions::findById($sess->user->sess_id)->id)) {
$user = new Model\User();
$user->logout($sess);
unset($sess->user);
$sess->setRequestValue('expired', true);
Response::redirect('/login');
exit;
} else {
if (isset($sess->user) && ($action == 'login' || $action == 'forgot' || $action == 'verify')) {
Response::redirect('/');
exit;
} else {
if (!isset($sess->user) && $action != 'login' && $action != 'forgot' && $action != 'verify') {
Response::redirect('/login');
exit;
}
}
}
}
示例2: logout
public function logout()
{
User::logout();
return redirect('/');
}
示例3: logout
/**
* Logout action method
*
* @return void
*/
public function logout()
{
if (isset($this->sess->user)) {
$user = new Model\User();
$user->logout($this->sess);
}
if ((int) $this->request->getQuery('expired') == 1) {
$this->sess->setRequestValue('expired', true);
}
$this->redirect('/login');
}