0

I have a index page where the user is redirected if enters from another URL from my website. I want to put a duration for this redirect with a session start. I have tried sending a cookie from the index page with the duration of the session, but it doesn´t work. How can I increase the duration of the session? I would be grateful if someone can help me. This is the code i am using.

index.php

<?php
    ini_set('session.gc_maxlifetime', 604800);
    session_set_cookie_params(604800);
    session_start();
    $_SESSION['welcome'] = true;
?>

page1.php, page2.php ...

<?php
    session_start();
    if(!$_SESSION['welcome']){
        header("location:/index.php");
        die;
    }
?>
Myky
  • 35
  • 6
  • you look here? https://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes – zbyso Jul 26 '22 at 15:45
  • Session GC settings _must_ be set at the global ini level as when GC happens it applies to _all_ sessions, not just the current one. – Sammitch Jul 26 '22 at 18:15

0 Answers0