Reputation: 1211
I am trying to disable cookies in my browser, and check that they are disabled in my .Net web app.
One on page I am storing a cookie like this:
HttpResponse response = HttpContext.Current.Response;
response.Cookies[cookieKey].Value = cookieValue.ToString();
On another page, I am retrieving the cookie like this:
cookieValue = request.Cookies[cookieKey].Value;
I am trying to disable cookies in my browser to make the above code fail but I can't seem to do that. I am using Internet Explorer 7 and 8. (I am working with these 2 browsers because IE7 is my company's current standard and IE8 is the future company standard).
In both of these browsers, I went to Internet Options >
Privacy >
Advanced, and checked override cookie handling, and blocked both 1st and 3rd party cookies (also deleted any existing cookies/history/temp files).
After doing that, I would expect the above code to not work, but it still works. I can still set and retrieve values from the cookie. Any idea why? I thought maybe the cookies aren't actually getting disabled, but if I go to hotmail.com
, it gives me an error message saying "Your browser must allow cookies before you can use Windows Live ID." so I don't know.
Why do cookies still work when visiting my ASP.Net site?
Updated 5/14/2012:
It appears that the cookie settings in the privacy tab are ignored on local intranet sites (I don't know if that is normal or not) so this was giving me problems. I did however figure out a different way to disable cookies (which I needed for testing purposes), even for intranet sites. In IE8, I went to Tools > Developer Tools > Cache > Disable Cookies. This worked as expected and i could complete my testing. However I still have not found a solution for IE7.
Upvotes: 1
Views: 1471
Reputation: 69993
Are you running the website locally?
I had a similar question I asked on SuperUser.
From what I can tell, Sparky was correct. localhost / 127.0.0.1 will always accept cookies regardless of your settings.
Upvotes: 3