From e57c37981242b05bc3e8dcaf610fe34845c5765b Mon Sep 17 00:00:00 2001 From: Sam White Date: Wed, 10 Nov 2021 21:01:55 +0000 Subject: [PATCH] Add mechanism to check user logged in status. --- public_html/includes/auth.php | 6 ++++++ public_html/includes/template.php | 2 ++ public_html/login.php | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 public_html/includes/auth.php diff --git a/public_html/includes/auth.php b/public_html/includes/auth.php new file mode 100644 index 0000000..3b1608e --- /dev/null +++ b/public_html/includes/auth.php @@ -0,0 +1,6 @@ + diff --git a/public_html/includes/template.php b/public_html/includes/template.php index 38ab376..2371f75 100644 --- a/public_html/includes/template.php +++ b/public_html/includes/template.php @@ -2,6 +2,8 @@ require_once('includes/utils.php'); require_once('includes/html-templating.php'); require_once('includes/navbar.php'); + +if (function_exists('pre_html')) pre_html(); ?> diff --git a/public_html/login.php b/public_html/login.php index 022ddeb..36c1b39 100644 --- a/public_html/login.php +++ b/public_html/login.php @@ -24,6 +24,10 @@ function validate_login(&$errors, $data) { return empty($errors) ? $record['id'] : false; } +function pre_html() { + session_start(); +} + function page_title() { return 'Login'; } @@ -38,7 +42,8 @@ function content() { $uid = validate_login($errors, $_POST); if ($uid) { esc('Login successful!.'); - die(); + $_SESSION['user'] = $uid; + return; } $params['email_address'] = $_POST['email_address']; }?> -- 2.25.1