-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cookies not working on localhost: redirect to 127.0.0.1 #196
Comments
Most interesting. Why not add a simple reminder to the error message? Instead of trying to work around the HTTP cookie spec? Like
|
This seems to not be an issue in Firefox, so displaying this error message would be a false positive there. And I have no plans to make Firefox respect this specification more strictly to the letter ;) localhost is an alias to 127.0.0.1, so I don't see redirecting from the former to the latter as being a "work around" the specs, just a different way to see things.
Seems complex to me. I would suggest doing the localhost to 127.0.0.1 redirection (then we address this specific case), and show an error message if the server name doesn't contain a dot, explaining they need to use the IP address instead. That:
(would the error message be shown to all browsers, or only Chrome-family? On the one hand you don't want false-positive mesages in Firefox, but how to make sure you cover all browsers that use Chrome's engine?) |
Yep. I don't think the message should only be show for chromium-based browsers (there are many many browsers out there and we don't know which ones are affected, plus the user agent detection is not really reliable). We could even skip the redirection/dot-in-server name detection for simplicity and add this to the current error message: Check that the hostname used to access Shaarli contains a dot. On some browsers, accessing your server via a hostname like 'localhost' or any custom hostname without a dot causes cookie storage to fail. We recommend accessing your server via it's IP address or Fully Qualified Domain Name This would prevent occasional confusion like in #97 Thoughts? |
I like the idea. Let's go with that, and maybe in the future "enhance" the experience by automatically redirect localhost (as that one is rather common and easy to figure out), while leaving other options just relying on the error message. |
Turns out by design domain names must have at least two dots to accept cookies:
Using Chromium in Debian, I was seeing the following error message after first installing Shaarli (while building the newest version of the Debian package) and going to http://localhost/shaarli :
After some time going through the code and adding debug statements, observing that the server was correctly sending back a set cookie header, not finding any logical reason why this was failing, I found the above-mentioned link and tried going to http://127.0.0.1/shaarli instead, which worked just fine.
I'd suggest adding a check to the
install()
function's Step 2: if the hostname is localhost, redirect to 127.0.0.1 (still with?test_session
)The text was updated successfully, but these errors were encountered: