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;
}
?>