-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDashboard.php
More file actions
33 lines (29 loc) · 768 Bytes
/
Dashboard.php
File metadata and controls
33 lines (29 loc) · 768 Bytes
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
29
30
31
32
33
<?php
session_start();
if (isset($_COOKIE['user_session'])) {
// Check if the session is valid
if (isset($_SESSION['user_id'])) {
// User is logged in
echo "Welcome back, " . $_SESSION['username'] . "!";
} else {
// Invalid session, redirect to login
header("Location: login.php");
exit();
}
} else {
// No cookie, redirect to login
header("Location: login.php");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dashboard</title>
</head>
<body>
<h1>Welcome, <?php echo htmlspecialchars($_SESSION['username'], ENT_QUOTES, 'UTF-8');// prevents potential XSS attacks, by escaping output ?>!</h1>
<a href="logout.php">Logout</a>
</body>
</html>