<?php
session_start();

if(empty($_SESSION['user_id'])){
    header("Location: ../login.php");
    exit;
}

// session timeout (30 mins)
if(isset($_SESSION['last_activity']) && (time() - $_SESSION['last_activity'] > 1800)){
    session_unset();
    session_destroy();
    header("Location: ../login.php");
    exit;
}

$_SESSION['last_activity'] = time();
