Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safari doesn't set Cookie but IE / FF does

I found a strange cookie problem on safari. If you surf to http://2much.ch you can enter with FF/IE and surf inside the site.

But if you use safari, you can enter only once; you can't surf inside the site. I found that Safari doesn't set the entered cookie, but FF/IE does.

What is wrong here?

like image 292
Gomez Avatar asked Jul 17 '09 18:07

Gomez


People also ask

How do I manually add cookies to Safari?

SAFARI for iOS (iPhone and iPad)Step 1: Go to Settings, then scroll down and select “Safari”. Step 2: Scroll down to “Privacy & Security”. Step 3: Verify “Block All Cookies” is ticked (green/white), click to allow cookies. Step 4: Clear the browser cache and reopen the browser.


1 Answers

It looks like you hit a Safari bug here; you are redirecting any visiting browser to /entry while setting the cookie at the same time, and Safari is ignoring the Set-Cookie header when encountering the 302 HTTP status:

$ curl -so /dev/null -D - http://4much.schnickschnack.info/ HTTP/1.1 302 Moved Temporarily Server: nginx/0.7.61 Date: Sun, 19 Jul 2009 12:20:49 GMT Content-Type: text/html;charset=utf-8 Connection: keep-alive Content-Length: 14260 Content-Language: de Expires: Sat, 1 Jan 2000 00:00:00 GMT Location: http://4much.schnickschnack.info/entry Set-Cookie: colorstyle="bright"; Path=/; Expires=1248092449.12 Set-Cookie: _ZopeId="73230900A39w5NG7q4g"; Path=/ 

Technically, this would be a bug in Apple's Foundation Classes, I've found a WebKit bug that states this is the case.

I suppose the workaround is to set the cookie not in index_html but in entry instead.

In the intervening years since I first answered this question, this issue now appears solved, at least it was for Safari 6 when someone tested all major browsers for Set-Cookie support on 302 redirects in 2012.

like image 143
Martijn Pieters Avatar answered Nov 06 '22 06:11

Martijn Pieters