Thursday, 5 September 2013

Cookie duplicated in document.cookie

Cookie duplicated in document.cookie

client = IE9, server = asp.net (a sharepoint application page to be exact)
In the Page_Load method of a page, I have the following code:
Response.Cookies["XXXXX"].Value =
tabtitles.IndexOf(Request.Params["tab"]).ToString();
Response.Cookies["XXXXX"].Expires = DateTime.Now.AddDays(1);
My cookie logic wasn't behaving as expected, so using the Console in IE
Developer Tools I've found that document.cookie had the following value:
>> document.cookie
"XXXXX=3;
WSS_KeepSessionAuthenticated={7da6dcd3-28b6-4c8f-b507-6fa80a16143c};
databaseBtnText=Open%20with%20Access;
databaseBtnDesc=Works%20with%20items%20in%20a%20Microsoft%20Access%20database%2E;
XXXXX=7"
as you can see, the cookie was appended to the end of document.cookie
instead of replaced. is this a bug in IE9? How can I correctly set and get
the cookie i want?

No comments:

Post a Comment