Файл: app/user/exit.php
Строк: 16
<?php
if (!$user->isAuth()) {
redirect('/');
exit;
}
if (isset($_POST['submit'])) {
if (isset($_POST['reset']) == true) {
$stmt = $db->prepare("DELETE FROM users_sessions WHERE user_id = :user_id");
$stmt->bindParam(':user_id', $user->getSession()->user_id, PDO::PARAM_INT);
$stmt->execute();
} else {
$stmt = $db->prepare("DELETE FROM users_sessions WHERE token = :token");
$stmt->bindParam(':token', $user->getSession()->token, PDO::PARAM_STR);
$stmt->execute();
}
setcookie('__session', null, -1, '/');
unset($_SESSION['__session']);
redirect('/');
exit;
}
echo $template->render('user.exit');