<?php
if (session_status() === PHP_SESSION_NONE) {
    $secure = (!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] !== "off");

    session_set_cookie_params([
        "lifetime" => 60 * 60 * 24 * 30,
        "path" => "/",
        "secure" => $secure,
        "httponly" => true,
        "samesite" => "Lax",
    ]);
}

ini_set("session.gc_maxlifetime", (string) (60 * 60 * 24 * 30));
