blob: 66a0cac7ebbf1763498800c7ac9a3fa37a6570e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<?php
include "../../src/utils.php";
include_once "../../src/config.php";
session_start();
if (!isset($_SESSION["user_id"])) {
header("Location: /account");
exit;
}
$db = new PDO(DB_URL, DB_USER, DB_PASS);
$stmt = $db->prepare("UPDATE users SET secret_key = ? WHERE id = ?");
$stmt->execute([generate_random_string(32), $_SESSION["user_id"]]);
session_unset();
session_destroy();
setcookie("secret_key", "", time() - 1000);
$db = null;
header("Location: /account");
|