cookies not working in safari?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jrucifer
Forum Commoner
Posts: 32
Joined: Fri May 13, 2005 2:36 pm
Location: phoenix

cookies not working in safari?

Post 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?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post 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)
jrucifer
Forum Commoner
Posts: 32
Joined: Fri May 13, 2005 2:36 pm
Location: phoenix

Post 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.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Have you checked the security settings in safari in relation to cookies?
jrucifer
Forum Commoner
Posts: 32
Joined: Fri May 13, 2005 2:36 pm
Location: phoenix

Post by jrucifer »

yes I have... it's set to always accpet cookies.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Try omitting the last 3 parameters you're using
jrucifer
Forum Commoner
Posts: 32
Joined: Fri May 13, 2005 2:36 pm
Location: phoenix

Post 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?
Post Reply