OK, I know there are a lot of cookie questions on the forum here, but I can't find anything about my particular issue.
On the homepage I want to check to see if the session cookie is already set. If there is no cookie, it checks for a session ID. If it exists, ini_set is used to disable session cookies.
When a user logs in, they can choose to set a cookie to not have one set. In the login script, ini_set is used to set cookies to TRUE and a session is started.
problem, the session is being created, but the cookie is never set.
login script
if($_POST['use_cookie'] == 'yes'){
ini_set('session.use_cookies',TRUE);
$redirect = "home.php";
session_start();
} else {
ini_set('session.use_cookies',FALSE);
session_start();
$redirect = "home.php?" . SESSION_NAME . "=" . session_id();
}
Checking for cookie in homepage
//SESSION_NAME is a constant defined in an include file.
session_name(SESSION_NAME);
if(isset($_COOKIE[SESSION_NAME])){
ini_set('session.use_cookies',TRUE);
if(isset($_SESSION['valid_user'])){ session_start(); }
} else {
if(isset($_SESSION['valid_user'])){
ini_set('session.use_cookies',FALSE);
session_start();
}
}
thanks,