cookies
by Robert Brim · in Technical Issues · 02/07/2002 (11:53 pm) · 2 replies
I am having an extremely hard time (my forehead is bloody from smashing into a brick wall) with getting a web site to accept return cookies.
If I make the users use session cookies, everything runs beautifully.
If I set the cookie so they can return, a blank white page comes up more often than not.
this is the code I use for setting the cookie (in php)
($info is encoded data)
$expires = $time+2592000;
setcookie("username",$info,$expires,"/","www.mgonetwork.com","");
then on the main page, it checks for a cookie. If it exists, it goes to the main entered area and checks for normal auth. Problem is, if the cookie is there, you get blank white pages.
If I make the users use session cookies, everything runs beautifully.
If I set the cookie so they can return, a blank white page comes up more often than not.
this is the code I use for setting the cookie (in php)
($info is encoded data)
$expires = $time+2592000;
setcookie("username",$info,$expires,"/","www.mgonetwork.com","");
then on the main page, it checks for a cookie. If it exists, it goes to the main entered area and checks for normal auth. Problem is, if the cookie is there, you get blank white pages.
About the author
#2
02/09/2002 (9:52 am)
When are you putting the setcookie() statement in? You have to do it before the headers are sent (right at the top of the script) or else they won't go. You'd get an error message if you had the setcookie() line in the middle, though (it'd say something like "error: headers already sent"). Give us more code or info about the setup if you can't find it. It'll help us figure out what's going on.
Torque 3D Owner Gareth Davies
A) The path that does something if it finds the cookie
B) The server software.
How much of a 'blank page' do you get. Does the server return anything at all (headers / blank HMTL etc)?
Sorry if this is really obvious but comment out the line that gets the cookie and replace the variable with what you'd expect. If it still dies then it ain't the cookie thats the problem.
The way cookies work is so simple I can't believe that simply retriving them creates a 'blank page' on it's own.
Glad i'm using M$ software (spine shivers). :)