Dateien nach "includes" hochladen

This commit is contained in:
2026-07-28 10:15:54 +00:00
parent 3b373ecf18
commit c6eec33d6d
5 changed files with 127 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* Session-Handling und Login-Hilfsfunktionen.
* Diese Datei muss VOR jeder Ausgabe eingebunden werden (session_start!).
*/
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
function is_logged_in() {
return !empty($_SESSION['user_id']);
}
function current_user_name() {
return $_SESSION['user_name'] ?? '';
}
/** Leitet zum Login um, falls niemand angemeldet ist. In geschützten Seiten ganz oben aufrufen. */
function require_login() {
if (!is_logged_in()) {
header('Location: login.php');
exit;
}
}