From 2b8b845abe7c13ecbb266613910484310cffe8e1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 5 Mar 2021 21:14:35 +0300 Subject: * use ORM for trivial queries * environment-based configuration * useradm.php -> update.php with new options * support for schema migrations * various fixes --- include/sessions.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 include/sessions.php (limited to 'include/sessions.php') diff --git a/include/sessions.php b/include/sessions.php new file mode 100644 index 0000000..b39a983 --- /dev/null +++ b/include/sessions.php @@ -0,0 +1,48 @@ +where('user', $_SESSION['owner']) + ->find_one(); + + if ($user && sha1($user->pass) == $_SESSION['pass_hash']) { + return true; + } + } + + return false; + } + + function logout_user() { + if (session_status() == PHP_SESSION_ACTIVE) { + session_destroy(); + + if (isset($_COOKIE[session_name()])) { + setcookie(session_name(), '', time()-42000, '/'); + } + + session_commit(); + } + } + + register_shutdown_function('session_write_close'); + + if (isset($_COOKIE[session_name()])) { + if (session_status() != PHP_SESSION_ACTIVE) + session_start(); + } +?> -- cgit v1.2.3