diff --git a/app/templates/page-footer.php b/app/templates/page-footer.php index 9e7c076..5248206 100644 --- a/app/templates/page-footer.php +++ b/app/templates/page-footer.php @@ -4,13 +4,74 @@ - - - - - +hasRight($userId, 'superuser'); + } + + if ($canSeeSessionDebug) { + Session::startSession(); + $remember = !empty($_SESSION['REMEMBER_ME']); + $timeoutSeconds = $remember ? (30 * 24 * 60 * 60) : 7200; + $lastActivity = $_SESSION['LAST_ACTIVITY'] ?? null; + + $remainingLabel = 'Session activity timestamp unavailable.'; + $expiresAtLabel = 'unknown expiry'; + + if ($lastActivity !== null) { + $elapsed = time() - (int)$lastActivity; + $secondsRemaining = max(0, $timeoutSeconds - $elapsed); + + $days = intdiv($secondsRemaining, 86400); + $hours = intdiv($secondsRemaining % 86400, 3600); + $minutes = intdiv($secondsRemaining % 3600, 60); + $seconds = $secondsRemaining % 60; + + $parts = []; + if ($days > 0) { + $parts[] = $days . ' ' . ($days === 1 ? 'day' : 'days'); + } + if ($hours > 0) { + $parts[] = $hours . ' ' . ($hours === 1 ? 'hour' : 'hours'); + } + if ($minutes > 0) { + $parts[] = $minutes . ' ' . ($minutes === 1 ? 'minute' : 'minutes'); + } + if ($seconds > 0 || empty($parts)) { + $parts[] = $seconds . ' ' . ($seconds === 1 ? 'second' : 'seconds'); + } + + $remainingLabel = implode(' ', $parts); + $expiresAtLabel = date('Y-m-d H:i:s', time() + $secondsRemaining); + } + + ob_start(); +?> + + Session debug: + session expires in () + + + + + + @@ -42,6 +103,5 @@ document.addEventListener('DOMContentLoaded', function() { }); - - + diff --git a/public_html/static/css/main.css b/public_html/static/css/main.css index 3d3c2c0..59edecc 100644 --- a/public_html/static/css/main.css +++ b/public_html/static/css/main.css @@ -1,3 +1,13 @@ +.tm-session-debug { + display: inline-block; + margin-left: 1rem; + background: #fff3cd; + color: #533f03; + border: 1px solid #ffe69c; + border-radius: 0.4rem; + font-size: 0.75rem; +} + .tm-profile-view { display: flex; flex-direction: column;