Page 2 of 2
Posted: Fri May 21, 2004 6:59 pm
by Unipus
Hrm... using this code and it's not changing the behavior. I have checked and am certain that the condition is evaluating true. But I still see the session id in the URL.
Code: Select all
setcookie("cookietest", "1", time()+86400*30);
///Sets it to expire in 30 days
if ($_COOKIE["cookietest"] == 1)
{
ini_set("session.use_only_cookies", "1");
}
Posted: Fri May 21, 2004 7:13 pm
by Unipus
Well I found the problem.
"For newcomers, cookies are ONLY available after you change the page that has set a cookie. In the new page you can see the cookie that was set accessing the $_COOKIE array."
I have not yet found the solution, exactly.
Posted: Fri May 21, 2004 7:21 pm
by launchcode
You cannot access a cookie on the same script as you set it, that isn't how they work. They're not active in the browser until the subsequent page call.
Posted: Fri May 21, 2004 7:52 pm
by Unipus
Hmm. Regardless of that, this script is called with every page load. And yet the PHPSESSID continues to appear even on subsequent pages, even when I know the cookie has taken. And I've restarted Apache and all that.
Posted: Fri May 21, 2004 11:46 pm
by feyd
From what I've seen, the php preprocessor keeps it there if it appeared on the first load...
Posted: Sat May 22, 2004 4:55 am
by launchcode
feyd - yeah, looks that way here on a quick test.
Just write a script that sets a cookie - redirect to another script (using a header location, so the user will never see it happen) which checks if the cookie exists - if not, use the trans ID, if so - set the use cookies on.
You'll need these as sort of "jump" pages through the start of your site. But like I said, if you use a header location: transfer then the user will NEVER see it happen.