Compare commits
No commits in common. "bccd48014bc107a1976f399cd323d9877f16f453" and "cfa8540be99acb7c2df84f370de97b57c66a3d1b" have entirely different histories.
bccd48014b
...
cfa8540be9
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
// Pages that should not be used as redirect targets
|
// Pages that should not be used as redirect targets
|
||||||
const INVALID_REDIRECT_PAGES = [
|
const INVALID_REDIRECT_PAGES = [
|
||||||
'', 'login', 'logout', 'register', 'dashboard', '/'
|
'', 'login', 'dashboard', '/'
|
||||||
];
|
];
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Session Middleware
|
||||||
|
*
|
||||||
|
* Validates session status and handles session timeout.
|
||||||
|
* If session is invalid, redirects to login page.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function applySessionMiddleware($config, $app_root, $isTest = false) {
|
||||||
|
// Start session if not already started
|
||||||
|
if (session_status() !== PHP_SESSION_ACTIVE) {
|
||||||
|
Session::startSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check session validity
|
||||||
|
if (!Session::isValidSession()) {
|
||||||
|
// Only show session timeout message if there was an active session
|
||||||
|
// and we haven't shown it yet
|
||||||
|
if (isset($_SESSION['LAST_ACTIVITY']) && !isset($_SESSION['session_timeout_shown'])) {
|
||||||
|
Feedback::flash('LOGIN', 'SESSION_TIMEOUT');
|
||||||
|
$_SESSION['session_timeout_shown'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Session invalid, clean up and redirect
|
||||||
|
Session::cleanup($config);
|
||||||
|
|
||||||
|
if (!$isTest) {
|
||||||
|
header('Location: ' . $app_root . '?page=login');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
Loading…
Reference in New Issue