本文整理汇总了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');
}