Safari doesn't like local cookies!

Posted:
in Mac Software edited January 2014
So I've just been banging my head on the wall, and I trust it's not just me being incredibly stupid or something...



I've been writing a website that does all sorts of fun things with cookies, but they just refused to behave properly with Safari, although IE runs them quite happily.



So, I have a hunt around in Safari's cookie basket, only to find that there are no cookies from the localhost. IE's got exactly the right cookies, belonging to... localhost.



GRRRRRRRRRAAAAAAAAAAHHHHHHHHH!



Good job it's not a complex site and I have a fast connection, so I can load it on a webserver and test it all from there, but it's slightly more work than I really wanted.



Yes, the bug report has gone in, but I need to release some steam... Thank you for your forbearance.

Comments

  • Reply 1 of 11
    kim kap solkim kap sol Posts: 2,987member
    What about chocolate chip...everyone loves chocolate chip cookies.
  • Reply 2 of 11
    costiquecostique Posts: 1,084member
    Very weird, you know. I was doing the same thing lately (2 weeks ago, maybe) and Safari cookies worked just fine (localhost-related). Even more weird, I couldn't get IE to load pages served at localhost. I tried everything: from localhost and www.localhost to http:/// and IE couldn't find it... unless I had an active Internet connection. Any other browsers (Safari, Netscape, Mozilla, Camino, OmniWeb, Opera) recognize localhost.
  • Reply 3 of 11
    overhopeoverhope Posts: 1,123member
    How odd... Are you using Safari beta 2?
  • Reply 4 of 11
    costiquecostique Posts: 1,084member
    Quote:

    Originally posted by Overhope

    How odd... Are you using Safari beta 2?



    This was beta 1, but I'll try beta 2 this evening.
  • Reply 5 of 11
    overhopeoverhope Posts: 1,123member
    Just another bit of detail, don't know if this will make any odds: I keep all my websites in Home/Sites, but I'm not actually running Personal Web Sharing, just opening the files.



    Never caused a problem to IE...



    Sidebar: that's the first serious time I've spent in IE in about two weeks, and it just made me appreciate Safari even more.
  • Reply 6 of 11
    Yeah safari does not like to work with cookies when your working with IP address`s... If your on your own computer try using localhost instead of 127.0.0.1 this kind of thing used to happen to me to..
  • Reply 7 of 11
    torifiletorifile Posts: 4,024member
    Make sure you define the path for your cookies. I spent weeks trying to figure that one out.
  • Reply 8 of 11
    costiquecostique Posts: 1,084member
    Quote:

    Originally posted by Overhope

    Just another bit of detail, don't know if this will make any odds: I keep all my websites in Home/Sites, but I'm not actually running Personal Web Sharing, just opening the files.



    Never caused a problem to IE...




    Wait. You aren't loading pages through Apache? Do you set cookies with JavaScript? If so, I just don't know how Safari handles them.

    I do it so: My sites are in ~/Sites, Web Sharing (aka Apache) is on and I browse the sites as if they were on a remote server. The only difference is in the address I point browsers to: instead of www.mycoolsite.org I type localhost. This is the recommended way of doing things, I should say, because it lets you test every aspect of web development, including PHP/Perl/SSI, just like in real life.

    What concerns cookies, the PHP handbook says you must set them before anything else is sent to a browser. I can only confirm the issue. I can't say if it matters anything with JavaScript, though. But, having made sure I set a cookie with PHP before a browser gets any HTML headers, I got it to work with every browser I could test. Another thing is that some browsers require the path set for a cookie; you can use "/" for a cookie to be valid throughout the site.



    I hope this helps.
  • Reply 9 of 11
    overhopeoverhope Posts: 1,123member
    Thanks, guys, that makes complete sense, and it works perfectly even with the javascript cookies (the cookies show up in Safari as being from localhostname.local, just FYI).



    Your assistance is much appreciated, I'll be doing it the web-sharing way in future. Wooh, maybe I'll even learn some PHP.



    Just goes to show how much tighter Safari is in terms of standards-compliance, I suppose.
  • Reply 10 of 11
    <p>Cookies are a feature of http. If you are not loading your pages over http (i.e. you use file:// to access your pages instead of http://) then it is completely illogical for <em>http</em> cookies to work.</p>



    <p>I can only assume that Internet Explorer implements some hack to associate cookies with file URIs. Again, cookies are meant to be sent as http headers so if a browser is not communicating over http then it has no obligation to support cookies. I guess I can see why this feature is useful but it is very much just a <em>hack</em>. It is unrelated to the standardness of Safari's implementation of http cookies.</p>



    <p>- Chris</p>



    <p>Ah! vBulletin should die! How dare it prevent me from using semantic markup in my post! You will all just have to live with my &lt;/&gt;'d html tags.</p>
  • Reply 11 of 11
    torifiletorifile Posts: 4,024member
    Quote:

    Originally posted by amitofu

    <p>Cookies are a feature of http. If you are not loading your pages over http (i.e. you use file:// to access your pages instead of http://) then it is completely illogical for <em>http</em> cookies to work.</p>



    <p>I can only assume that Internet Explorer implements some hack to associate cookies with file URIs. Again, cookies are meant to be sent as http headers so if a browser is not communicating over http then it has no obligation to support cookies. I guess I can see why this feature is useful but it is very much just a <em>hack</em>. It is unrelated to the standardness of Safari's implementation of http cookies.</p>



    <p>- Chris</p>



    <p>Ah! vBulletin should die! How dare it prevent me from using semantic markup in my post! You will all just have to live with my &lt;/&gt;'d html tags.</p>




    I don't know if you did that on purpose, but it was funny as hell.
Sign In or Register to comment.