本文整理汇总了PHP中Web::sessionDestroy方法的典型用法代码示例。如果您正苦于以下问题:PHP Web::sessionDestroy方法的具体用法?PHP Web::sessionDestroy怎么用?PHP Web::sessionDestroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Web
的用法示例。
在下文中一共展示了Web::sessionDestroy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logout_GET
function logout_GET(Web &$w)
{
if ($w->Auth->loggedIn()) {
// Unset all of the session variables.
$w->sessionDestroy();
}
$w->redirect($w->localUrl("/auth/login"));
}
示例2: resetpassword_POST
function resetpassword_POST(Web $w)
{
$email = $w->request('email');
// email
$token = $w->request('token');
// token
$password = $w->request('password');
// password
$password_confirm = $w->request('password_confirm');
if ($password !== $password_confirm) {
$w->error("Passwords do not match", "/auth/resetpassword?email={$email}&token={$token}");
return;
}
$user = $w->Auth->getUserForToken($token);
//getObject("User", array("password_reset_token", $token));
$validData = false;
if (!empty($user->id)) {
// Check that the password reset hasn't expired
if (time() - strtotime($user->dt_password_reset_at) < 0) {
$w->msg("Your token has expired (max 24 hours), please submit for a new one", "/admin/forgotpassword");
return;
}
$user_contact = $user->getContact();
if (!empty($user_contact)) {
if ($user_contact->email == $email) {
$user->setPassword($password);
$user->password_reset_token = null;
$user->dt_password_reset_at = null;
$user->update(true);
// Precautionary logout
if ($w->Auth->loggedIn()) {
$w->sessionDestroy();
}
$validData = true;
}
}
}
if (!$validData) {
$w->Log->warn("Password reset attempt failed with email: {$email}, token: {$token}");
$w->out("Invalid email or token, this incident has been logged");
} else {
$w->msg("Your password has been reset", "/auth/login");
}
}