Reputation: 5556
I have a Rails application hosted on Heroku and I am preparing to deploy another application that will use the same session cookie. Let's assume that main application is hosted at app.mycompany.com
and the new application will be hosted at reports.mycompany.com
. I've setup session cookies in both apps with cookie domain .mycompany.com
and everything works ok. I've modified /etc/hosts
to test those settings on my local machine.
Since everything worked fine on my local machine I wanted to test it on our staging environment, which is hosted at mycompany-staging.herokuapp.com
. For this app I've set cookie domain to .herokuapp.com
. And now it does not work. It is not possible to login. From inspector it looks like correct Set-Cookie
header is sent from the server, but the browser never send this cookie back on request.
The same thing happens on my local machine when pointing mycompany-staging.herokuapp.com
to 127.0.0.1
. This happens only when I use herokuapp.com
. Everything else works fine or at least couple of different domains work fine, including herokuapp2.com
.
I am really confused. It looks like there is some cache issue, but I don't know where exactly. I am testing this mostly on Chrome with incognito mode, but I also tried Safari with the same problem.
Can anyone point me in the right direction? Or maybe I am missing something obvious.
Upvotes: 1
Views: 498
Reputation: 16226
This is because herokuapp.com
is included in the Mozilla Foundation’s Public Suffix List. Cookie with domain *.herokuapp.com
cannot be set any more. Refer to doc in devcenter.heroku.com:
herokuapp.com is included in the Mozilla Foundation’s Public Suffix List. This list is used in recent versions of several browsers, such as Firefox, Chrome and Opera, to limit how broadly a cookie may be scoped. In other words, in browsers that support the functionality, applications in the herokuapp.com domain are prevented from setting cookies for *.herokuapp.com. Note that *.herokuapp.com cookies can currently be set in Internet Explorer, but this behavior should not be relied upon and may change in the future.
Upvotes: 3