Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Can cookies be stored by IP address instead of domain name?
First, here's what I'm trying to accomplish: I want to use my static IP address as a cookie-less domain. Let's say my domain is xyz.com and my DNS record points xyz.com to 100.200.300.400 (my static IP address). My code (accessed through xyz.com) uses cookies. I want my images, scripts, and stylesheets to be accessed through 100.200.300.400. I am hoping that this will stop the cookies from being sent along with the images, scripts, and style sheets.
So the question is: If I access my images, scripts, and style sheets through my IP address and never set any cookies on the IP address, will I avoid sending cookies along with every request?
Dear CanadaRam: I am sorry, but the information you are giving me is incorrect. Please check the Wikipedia article at http://en.wikipedia.org/wiki/HTTP_cookie#Domain_an... for more information. The cookie that is stored on the user's computer specifies the domain and path from which it came. Only that domain and path (and its subpaths) can access that cookie.
3 Answers
- YeeLv 49 years agoFavorite Answer
Nowhere in HTTP specification say it can be an IP address. So the question boil down to, if we set cookie with an IP address in place of domain name, will the browser accept it, and set it back in the next request? I tested it (browser is firefox) and this is what I found:
It does work when I test it on local machine, but only if the URL is using the same IP address as coded in cookie. My localhost is bound to IP 192.168.1.100 and 127.0.0.1. If in my test.php I set cookie using 192.168.1.100, then it will work only if the URL is http://192.168.1.100/test.php. It will not work if the URL is http://127.0.0.1/test.php or http://localhost/test.php.
It does not work on my server which is hosted by yahoo.
The reason why it does not work on my server is clearly because it is a shared hosting, one server hosting many web sites and they all have the same IP. And I cannot access my website using its IP address the first place.
By default accessing images or style sheets should not have any cookie set as a result, unless you configure your web server or web site to do so. Rather than trying to set cookie using such unnatural way, you should investigate why your website sets cookie on everything and fix the problem from its root.
- CanadaRAMLv 79 years ago
Cookies have nothing to do with your domain or your domain's IP address.
Cookies are stored on your computer's web browser temporary files area.
When you go out to browse a website, it will write cookies to your hard drive unless you have them blocked in your browser. What domain you own has no relationship to this.
- Anonymous7 years ago