diff options
Diffstat (limited to 'public/account/signout.php')
| -rw-r--r-- | public/account/signout.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/public/account/signout.php b/public/account/signout.php new file mode 100644 index 0000000..dd1d0f9 --- /dev/null +++ b/public/account/signout.php @@ -0,0 +1,25 @@ +<?php +include "../../src/utils.php"; + +session_start(); + +if (!isset($_SESSION["user_id"])) { + header("Location: /account"); + exit; +} + +$db = new SQLite3("../../database.db"); + +$stmt = $db->prepare("UPDATE users SET secret_key = :secret_key WHERE id = :id"); +$stmt->bindValue(":id", $_SESSION["user_id"]); +$stmt->bindValue(":secret_key", generate_random_string(32)); +$stmt->execute(); + +session_unset(); +session_destroy(); + +setcookie("secret_key", "", time() - 1000); + +$db->close(); + +header("Location: /account");
\ No newline at end of file |
