I'm wondering why there's a difference in these two for sessions? If i have a login form and it passes sessions to a page (ie: settings.php). If i have localhost/settings.php the session would work, if I go to a different page and come back. but if it is 127.0.0.1/settings.php, the session will work on the first pass, then if I redirect somewhere else and go back, its not there anymore.
Does this happen to other people too? Or is this just me?
Thanks
Maybe this will help: http://www.issociate.de/board/post/179979/Cookie_Problems_on_Localhost.html
both 'localhost' and any ip are not accepted as valid domain-identifiers in cookies (as per RFC).
and 127.0.0.1 != localhost for browser. browser will not send cookie that was set from 127.0.0.1 to localhost, because they are different domains.
p.s. in practice, there can be many domains on one ip. and for security reasons, of course, browser can't send all cookies altogether (imagine, that cookies from your website could be sent by browser to all websites on virtualhosting with the same ip).
Due to the problems referenced in @true's answer, in our development we usually create a fake local domain like dev.localhost.net and use the hosts file to map this either to the machine ip address or to 127.0.0.1. This helps get around the session/cookie problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With