Cookie problems and safari? (Calling web devs for help)

Posted:
in Genius Bar edited January 2014
I've spent way too long trying to figure this out with my site, but for some reason Safari would not set cookies with the appropriate path. If not explicitly specified, the path would be listed as specific to that page. So, if I had a page "login_success.php" the cookie set on that page as a result of the successful login would only work for that page. So, despite being logged in successfully, the user would never appear so except on that specific page.



Now, I'm just a cookie novice, so I don't know if that's how it's supposed to work. Can anyone shed some light on this issue for me?



TIA.

Comments

  • Reply 1 of 7
    torifiletorifile Posts: 4,024member
    It doesn't appear to be a problem with leaving the setting blank, as I had been. Here's the setcookie function description, specifically related to the path variable of setcookie():



    [quote]

    If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in.

    <hr></blockquote>



    It doesn't make any sense that the path would be set to a specific file as it has been. It works fine in other browsers, btw. Maybe they're being more forgiving?



    So, is it a Safari issue or am I doing something wrong? BTW, I've already sent a bug-report to Apple in case it's a bug...
  • Reply 2 of 7
    torifiletorifile Posts: 4,024member
    bump.



    Come on, someone must know the answer or have seen the issue, right?
  • Reply 3 of 7
    Like you I have found various browsers accept cookies in different ways when you don't specify a path. I have even found that specifying / as your path doesn't always work correctly.



    I have gotten around the issue by declaring '' (that is two single quotes) as the path in my setcookie function. Some browsers choke if you don't specify every argument explicitly. So in PHP (setcookie - PHP right?) I use this syntax:

    [code]

    $cookie = setcookie('name', 'value', 'time()+3600', '', 0)

    if ($cookie !== 1) {

    echo "CRAP!";

    } else {

    echo "HOLY CRAP!";

    }</pre><hr></blockquote>
  • Reply 4 of 7
    torifiletorifile Posts: 4,024member
    [quote]Originally posted by The Pie Man:

    <strong>Like you I have found various browsers accept cookies in different ways when you don't specify a path. I have even found that specifying / as your path doesn't always work correctly.



    I have gotten around the issue by declaring '' (that is two single quotes) as the path in my setcookie function. Some browsers choke if you don't specify every argument explicitly. So in PHP (setcookie - PHP right?) I use this syntax:

    [code]

    $cookie = setcookie('name', 'value', 'time()+3600', '', 0)

    if ($cookie !== 1) {

    echo "CRAP!";

    } else {

    echo "HOLY CRAP!";

    }</pre><hr></blockquote></strong><hr></blockquote>



    Ah, thanks. I'm a n00b programmer and I'm always unsure if I'm doing things right. Glad to see it's not me.
  • Reply 5 of 7
    [quote]Ah, thanks. I'm a n00b programmer and I'm always unsure if I'm doing things right. Glad to see it's not me. <hr></blockquote>



    That's ok - I'm a complete hack - I always think I am doing it right until I get all kinds of error messages spewing across the page. :eek:
  • Reply 6 of 7
    I to have had cookie problems with safari... My cookies do work and safari remembers then but for some reason safari either doesnt like my header or i dunno but it makes me mad...
  • Reply 7 of 7
    [quote]Originally posted by Mount_my_floppy:

    <strong>I to have had cookie problems with safari... My cookies do work and safari remembers then but for some reason safari either doesnt like my header or i dunno but it makes me mad...</strong><hr></blockquote>



    More info?
Sign In or Register to comment.