Safari doesn't like local cookies!
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.
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
Originally posted by Overhope
How odd... Are you using Safari beta 2?
This was beta 1, but I'll try beta 2 this evening.
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.
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.
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.
<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 </>'d html tags.</p>
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 </>'d html tags.</p>
I don't know if you did that on purpose, but it was funny as hell.