Page 1 of 1
cookies not working in safari?
Posted: Sun Jan 29, 2006 12:39 am
by jrucifer
I'm just trying to do a basic setcookie to keep track of users. I've tested my pages in explorer and netscape, but for some reason it will not set the cookie in safari. I'm using this code as a test:
Code: Select all
<?php
$username = 'jrucifer';
setcookie("username", "$username", time()+3600, "/", ".skateaz.com", 0);
print_r($_COOKIE);
echo $_COOKIE["username"];
?>
i have the latest version of safari and i've checked my cookies settings. cookies on other sites work fine, but for some reason it will not set the cookie for my website. any idea what could be causing the problem?
Posted: Sun Jan 29, 2006 2:03 am
by josh
The cookies are not supposed to be sent back to the same page that set it (in one http request).
it [the http request] looks like this
your browser requests the page and sends any cookies it already has
server sets the cookie
so on the first connection the page has already been requested without any cookies being sent to your script, this is why you will not see the cookie being set on the same page like you posted. As for why it worked with firefox it might've done a HEAD request to get the cookies before loading up the page? It also might be related to multi-piping (multiple requests per page to speed up loading)
Posted: Sun Jan 29, 2006 2:51 am
by jrucifer
that makes sense, but even if i request the cookie from another page, or look for the cookie itself on my hard drive, it isnt there. its not setting it at all. unless i use a browser other than safari and then it will set it.
Posted: Sun Jan 29, 2006 9:28 am
by d3ad1ysp0rk
Have you checked the security settings in safari in relation to cookies?
Posted: Sun Jan 29, 2006 12:39 pm
by jrucifer
yes I have... it's set to always accpet cookies.
Posted: Sun Jan 29, 2006 2:02 pm
by josh
Try omitting the last 3 parameters you're using
Posted: Tue Jan 31, 2006 1:20 am
by jrucifer
still not working... this is very strange...
all other cookies work for me in safari
using the most basic setcookie string, the cookie works in other browsers but not safari...
what could be causing this problem?