how to create cookie or session that not expires on browser close i created some cookies and session they work till i close browser or logingout but i dont want like this i want the sessions and cookies remain if and only if
the users logout by theirself from website
and this is login.php session and cookie after email and password verification become true:
$_SESSION['loggedIn'] = true;
$cookie_name = "user";
$cookie_value = "websitename";
setcookie($cookie_name, $cookie_value);
header("location:profile.php");
and this is what profile.php session:
if ( !$_SESSION['loggedIn'] ) {
header("location: index.php");
}
and this is what logout.php session and cookie:
session_unset();
session_destroy();
setcookie("user", "", time() - 3600);
also this is the index.php cookie and sesssion:
if(isset($_COOKIE['user'] ) || isset($_SESSION['loggedIn']) )
{
header("location:profile.php");
}