<?php 
    include __DIR__ . "/../assets/folder_name.php"; 
    session_set_cookie_params([ 
        'path' => '/',
        'domain' => '',                   // Use current domain
        'secure' => isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on', // Only HTTPS
        'httponly' => true,               // JS cannot access session cookie
        'samesite' => 'Strict'            // Protect against CSRF
    ]); 

    session_start();

    if (
        isset($_SESSION['user_agent'], $_SESSION['ip']) &&
        (
            $_SESSION['user_agent'] !== $_SERVER['HTTP_USER_AGENT'] ||
            $_SESSION['ip'] !== $_SERVER['REMOTE_ADDR']
        )
    ) {
        session_unset();
        session_destroy(); 
        header("Location: " . $folder_name . "erp/login.php");
        exit;
    }

    $url_link = $_SERVER['SERVER_NAME'];

    if (!isset($_SESSION['skybots_user_id'])) {
?>
        <script>
            var fullurl="<?php echo $folder_name . 'erp/login.php'; ?>";
            window.top.location.href = fullurl;
        </script>
<?php 
    } 
?>