-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.php
More file actions
31 lines (26 loc) · 783 Bytes
/
config.php
File metadata and controls
31 lines (26 loc) · 783 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
<?php
// Prevent multiple session starts
if (session_status() === PHP_SESSION_NONE) {
// Move ini_set() before session_start()
ini_set('session.cookie_httponly', 1);
ini_set('session.cookie_secure', 1);
session_start();
}
// Set session timeout (30 minutes)
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
session_unset();
session_destroy();
header("Location: auth/login.php");
exit();
}
$_SESSION['LAST_ACTIVITY'] = time();
// Secure Database Connection
$host = "localhost";
$user = "root";
$pass = "";
$dbname = "college_management";
$conn = new mysqli($host, $user, $pass, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>