<?php
// Extend session life (24 hours)
ini_set('session.gc_maxlifetime', 86400);
session_set_cookie_params(86400);

session_start();

// Refresh session if remember_me cookie exists
if (!isset($_SESSION['adminNo']) && isset($_COOKIE['remember_me'])) {
    include 'db.php';
    $token = $_COOKIE['remember_me'];

    $stmt = $pdo->prepare("SELECT * FROM student WHERE remember_token = ?");
    $stmt->execute([$token]);
    $user = $stmt->fetch(PDO::FETCH_ASSOC);

    if ($user) {
        $_SESSION['adminNo'] = $user['adminNo'];
    }
}
?>
