sethb11 / Newrepo

0 stars 0 forks source link

sessions.php #3

Open papichulo16 opened 1 year ago

papichulo16 commented 1 year ago

HI

papichulo16 commented 1 year ago

<?php session_start(); $logged_in = $_SESSION["logged_in"] ?? false;

function login() {
    session_regenerate_id(true);
    $_SESSION["logged_in"] = true;
}

function logout() {
    $_SESSION = [];

    $params = session_get_cookie_params();
    setcookie("PHPSESSID", "", time() - 3600, $params["path"], $params["domain"]
    , $params["secure"], $params["httponly"]);

    session_destroy();
}

function require_login($logged_in) {
    if ($logged_in == false) {
        header("Location: login.php");
        exit;
    }
}

?>

papichulo16 commented 1 year ago

[

sessions.zip

](url)