For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > July 2007 > cookies not persisting









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cookies not persisting
John Grandy

2007-07-27, 7:10 pm

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);



Riki

2007-07-28, 7:09 pm

John Grandy wrote:
> 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.

--

Riki


John Grandy

2007-07-30, 7:11 pm

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.

"Riki" <riki@dontnagme.com> wrote in message
news:Ox9nxqR0HHA.5152@TK2MSFTNGP02.phx.gbl...
> John Grandy wrote:
>
> 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.
>
> --
>
> Riki
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com