Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I set a cookie and redirect?

I'm having a problem setting a cookie and doing a 302 redirect
In chrome the cookie is not being set (I haven't tested safari), in other browsers I was having the same problem until I added Path=/ to the cookie an now it works.

This is how the header looks; the status is 302 Found

Content-Type    text/html; charset=iso-8859-1 Expires Thu, 01 Jan 1970 00:00:00 GMT Set-Cookie  alasca-flash=error-Message<Required<error-Name<Required<error-Sex<Required<error-Age<Required<;Path=/ Location    /messages/sdf Content-Length  0 Server  Jetty(6.1.x) 

Any idea on why the cookie is not set? Or any workaround?

like image 746
Damian Avatar asked Oct 25 '09 17:10

Damian


People also ask

Can you set-cookie on redirect?

2), Opera (12.11) both on Windows and Mac, set cookies on redirects. This is true for both 301 and 302 redirects. The SameSite attribute of a cookie specifies whether the cookie should be restricted to a first-party or same-site context.

Can you set cookies for another domain?

You cannot set cookies for another domain. Allowing this would present an enormous security flaw.

How do I set cookies to all path?

In your Java server, you should call cookie. setPath("/") before adding it to response. Such cookie will match all request URIs.


1 Answers

See this question: Safari doesn't set Cookie but IE / FF does

It mentions this bug report in WebKit (due to AFC)

like image 90
DVK Avatar answered Oct 05 '22 15:10

DVK