-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsession.php
More file actions
28 lines (22 loc) · 1.14 KB
/
Copy pathsession.php
File metadata and controls
28 lines (22 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
require __DIR__ . '/vendor/autoload.php'; // Ścieżka do autoload.php z biblioteki firebase/php-jwt
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
// Klasa reprezentująca zdekodowany token JWT
class DecodedToken {
public $user_id;
public $exp;
public function __construct($user_id, $exp) {
$this->user_id = $user_id;
$this->exp = $exp;
}
}
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
if (!isset($_SESSION['jwt'])) {
// Jeśli token JWT nie jest ustawiony w sesji, przekieruj użytkownika na stronę logowania
header("Location: LoginPage.php");
exit(); // Upewnij się, że skrypt przestaje wykonywać się po przekierowaniu
}
?>