Jump to content

[SOLVED] Safari can't read , Firefox OK


iwannabeleet

Recommended Posts

I have an index.php page which sets a cookie:

 

<?php
setcookie('showpopup',1);
?>

 

and has a brief flash animation which later automatically sends the user to the main page (index2.php), where the cookie is checked:

 

if(isset($_COOKIE['showpopup']))
{ //dostuff}

 

So now I'm really confused because in Firefox & IE (i think) the code works in great, but in Safari, the ISSET is returning false. But here's the crazy thing, I check Safari's Cookies window and it shows the cookie right there, with a value of 1  ???. So it's set in the browser, but somehow the ISSET is returning false in Safari.

 

Anyone have any clue what could be causing this??

Link to comment
Share on other sites

well m aybe safari stores the cookies but theres a problem with teh domain to which they are saved?? im not to good with cookie domains -0 the another thig could be that safari proccesses them differently and therefore th page is setting the cookie and then readig form teh cookie before its been written?

 

either way , gdlk

Link to comment
Share on other sites

I'm wondering if part of this has to do with the situation of whether or not the URL has 'www' in front of it. It seems that the $_COOKIE isn't read if it was set by 'http://example.com/index.php' and then tries to get read by 'http://www.example.com/otherpage.php'

 

I'm probably venturing out of PHP territory and now into more webserver territory but does anyone know if that might be the cause, and if so how I can remedy this?

 

thank you in advance

Link to comment
Share on other sites

well m aybe safari stores the cookies but theres a problem with teh domain to which they are saved??

 

oops I just posted about that, yeah I think you're exactly right, although now I'm trying to figure out the best way to solve this problem. I have no way of knowing if a user will actually visit the domain from 'www.example.com' or just type in 'example.com' and my initial re-direct has to be hardcoded to one of those, so either way sometimes it will be wrong. I hope i'm making sense....

Link to comment
Share on other sites

Sorry for posting so much without googling first, the problem was easily solved with that domain parameter of setcookie:

 

bool setcookie  ( string $name  [, string $value  [, int $expire  [, string $path  [, string $domain  [, bool $secure  [, bool $httponly  ]]]]]] )

 

domain

 

    The domain that the cookie is available. To make the cookie available on all subdomains of example.com then you'd set it to '.example.com'. The . is not required but makes it compatible with more browsers. Setting it to www.example.com will make the cookie only available in the www subdomain. Refer to tail matching in the » spec for details.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.