edaj6
asked on
cookie not working in internet explorer
I am trying to add a cookie to an intranet page. It works fine on local host when testing, both ie8 and firefox. When I publish to iis7 it only works in firefox.
I am not getting any errors in ie8, the cookie is just not saved. Security is set to local intranet/low.
I am not getting any errors in ie8, the cookie is just not saved. Security is set to local intranet/low.
protected void lnkLoadCookie_Click(object sender, EventArgs e)
{
HttpCookie MyCookie = Request.Cookies["testcookie"];
if (MyCookie != null)
lnkCookie.Text = MyCookie.Values["test"];
else
lnkCookie.Text = "no cookie";
}
protected void lnkSaveCookie_Click(object sender, EventArgs e)
{
HttpCookie aCookie = new HttpCookie("testcookie");
aCookie.Values["test"] = "testvalue";
aCookie.Expires = DateTime.Now.AddYears(1);
lnkCookie.Text = "cookie saved";
Response.Cookies.Add(aCookie);
}
on dev it always works fine
but can you try the following (copied from somewhere)
"I have some suggestions to add to those that Debbie made. IE8 has an option for InPrivate Browsing. If you are browsing in this mode no cookies or history is saved. The easiest way to see if you are in this mode is there will be a blue bar at the beginning of the address bar that says “InPrivate”. This is activated by going to the “Safety” button on the Menu Bar and selecting InPrivate Browsing. When you close and re-launch IE8 you should be returned to normal browsing. If this hasn’t been turned on then the security settings in IE8 have been set to NOT allow cookies or you could be running third party internet security software program that is blocking cookies. We can check the IE8 security settings by going to the “Tools” button on the Menu Bar and clicking Internet Options. Click on the Security tab and click on the icon for Internet. The slide adjuster just below Security Level for This Zone by default is set to Medium-High. This setting does allow cookies so try setting to this level. Now click on the Privacy tab. The slide adjuster below Select a Setting for the Internet Zone is set to Medium by default. This setting will allow the type of cookies that you are referring to so if it is not set to Medium set it there. Click Apply and click OK. Now close and restart IE8 and see if you can set the passwords you are referring to. Close IE8 and reboot. Did the cookies save? If not could you let us know if you are using an Internet Security software package or Antivirus program? This will allow us to assist you with further troubleshooting."
but can you try the following (copied from somewhere)
"I have some suggestions to add to those that Debbie made. IE8 has an option for InPrivate Browsing. If you are browsing in this mode no cookies or history is saved. The easiest way to see if you are in this mode is there will be a blue bar at the beginning of the address bar that says “InPrivate”. This is activated by going to the “Safety” button on the Menu Bar and selecting InPrivate Browsing. When you close and re-launch IE8 you should be returned to normal browsing. If this hasn’t been turned on then the security settings in IE8 have been set to NOT allow cookies or you could be running third party internet security software program that is blocking cookies. We can check the IE8 security settings by going to the “Tools” button on the Menu Bar and clicking Internet Options. Click on the Security tab and click on the icon for Internet. The slide adjuster just below Security Level for This Zone by default is set to Medium-High. This setting does allow cookies so try setting to this level. Now click on the Privacy tab. The slide adjuster below Select a Setting for the Internet Zone is set to Medium by default. This setting will allow the type of cookies that you are referring to so if it is not set to Medium set it there. Click Apply and click OK. Now close and restart IE8 and see if you can set the passwords you are referring to. Close IE8 and reboot. Did the cookies save? If not could you let us know if you are using an Internet Security software package or Antivirus program? This will allow us to assist you with further troubleshooting."
ASKER
thanks for comments.
mplungjan: I use .values because I want to add more values later. I have tested with .value and .path - no difference
ragi0017: I have tested what you suggest. I am not in inPrivate mode, the zone is local intranet and security is set to low, allowing all.
On IE8 I can browse to http://localhost and everything works, when published to intranet it doesn't work. Same browser, same zone, same settings. I suspect it must be something with IIS7 on intranet being different from my localhost.
mplungjan: I use .values because I want to add more values later. I have tested with .value and .path - no difference
ragi0017: I have tested what you suggest. I am not in inPrivate mode, the zone is local intranet and security is set to low, allowing all.
On IE8 I can browse to http://localhost and everything works, when published to intranet it doesn't work. Same browser, same zone, same settings. I suspect it must be something with IIS7 on intranet being different from my localhost.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Didn't solve problem, but I found a work around.
HttpCookie aCookie = new HttpCookie("testcookie");
aCookie.Value= "testvalue";
aCookie.Path= "/";
aCookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(aCook