cookies not persisting

J

John Grandy

I'm not finding cookies I create to persist. I don't see any corresponding
file in

C:\Documents and Settings\jgrandy\Local Settings\Temporary Internet Files

and the cookie is not present in the Request.Cookies collection on postback.

Here is how I am creating the cookie :

HttpCookie cookie = new HttpCookie("MyCookie");
cookie.Expires = DateTime.Now.AddYears(1);
cookie.Value = "written " + DateTime.Now.ToString();
cookie.Path = "folder1/folder2";
Response.Cookies.Add(cookie);
 
R

Riki

John said:
I'm not finding cookies I create to persist. I don't see any
corresponding file in

C:\Documents and Settings\jgrandy\Local Settings\Temporary Internet
Files
and the cookie is not present in the Request.Cookies collection on
postback.
Here is how I am creating the cookie :

HttpCookie cookie = new HttpCookie("MyCookie");
cookie.Expires = DateTime.Now.AddYears(1);
cookie.Value = "written " + DateTime.Now.ToString();
cookie.Path = "folder1/folder2";
Response.Cookies.Add(cookie);

When you set the Path to "folder1/folder2", the cookie will only apply to
files in that folder.
Is your page in that folder?

Secondly, cookies for Internet Explorer are not kept in C:\Documents and
Settings\jgrandy\Local Settings\Temporary Internet Files, but in
C:\Documents and Settings\jgrandy\Cookies.
 
J

John Grandy

Cookies show in both folders. I'm not sure why Explorer shows them that way,
and I'm not sure where they actually are located, but that's how Explorer
shows them.

My page is in the folder pointed to by Cookie.Path, but that setting did
turn out to be the culprit. Not sure why.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top