I am using IE8 and Visual Studio 2008 developing a SQL application and I have started to use a couple of cookies to assist in state management. Oddly enough I can see and delete all the cookies that get collected in the temp folder by browsing the internet,
but I can never see the ones that are created by my visual studio program. In stepping through the code I can tell that they are created because I am using an "If not is nothing" then...
So how do I see the cookie in the temp folder. I want to view it there and open it and see what is inside. Any ideas?
If you do not set the cookie's expiration, the cookie is created but it is not stored on the user's hard disk. Instead, the cookie is maintained as part of the user's session information. When the user closes the browser, the cookie is discarded. A
non-persistent cookie like this is useful for information that needs to be stored for only a short time or that for security reasons should not be written to disk on the client computer. For example, non-persistent cookies are useful if the user is working
on a public computer, where you do not want to write the cookie to disk.
Thanks Smirnov, I set the cookie to expire now.adddays(1) but still couldn't find the cookie in C:\Documents and Settings\John\Local Settings\Temporary Internet Files. Here is the code below. Steppin through the code I can see that the "add cookie" code
is executed.
Any ideas why I still don't see the cookie in that particular folder? That is the folder that comes up when I hit IE8/Tools/Internet Options General Tab/Browsing History Settings button/View files button.
'/// Check to see if the OKS cookie already exists
If HttpContext.Current.Request.Cookies("OKS") Is Nothing Then '/// it doesn't exist so create one
'/// Write a working cookie to hold all the variables
Dim anotherCookie As New HttpCookie("OKS")
anotherCookie.Values("Dojo") = "dojoID"
anotherCookie.Values("Course") = "courseID"
anotherCookie.Values("Family") = "familyID"
anotherCookie.Values("Member") = "memberID"
anotherCookie.Expires = DateTime.Now.AddDays(1)
HttpContext.Current.Request.Cookies.Add(anotherCookie)
Else '/// it exists already so let's get the values
Dim sDojo As String '= something
Dim sCourse As String '= something
Dim sFamily As String '= something
Dim sMember As String '= something
'/// more code
End If
Pradeep I don't have a cookies folder, I do have C:\Documents and Settings\John\Local Settings\Temporary Internet Files but my cookies don't appear there - any other ideas?
Ok, I figured it out with some help. I wasn't using Response. Instead I was using Request. Here is the right way to load a cookies at the class level:
'/// Write a working cookie to hold all the variables
Dim anotherCookie As New HttpCookie("OKS")
anotherCookie.Values("Dojo") = "dojoID"
anotherCookie.Values("Course") = "courseID"
anotherCookie.Values("Family") = "familyID"
anotherCookie.Values("Member") = "memberID"
anotherCookie.Expires = DateTime.Now.AddDays(1)
HttpContext.Current.Response.Cookies.Add(anotherCookie)
John
Marked as answer by tualatin on Dec 30, 2011 01:54 AM
Tualatin
Member
131 Points
172 Posts
how to view a cookie
Dec 27, 2011 01:28 PM|LINK
I am using IE8 and Visual Studio 2008 developing a SQL application and I have started to use a couple of cookies to assist in state management. Oddly enough I can see and delete all the cookies that get collected in the temp folder by browsing the internet, but I can never see the ones that are created by my visual studio program. In stepping through the code I can tell that they are created because I am using an "If not is nothing" then...
So how do I see the cookie in the temp folder. I want to view it there and open it and see what is inside. Any ideas?
smirnov
All-Star
24624 Points
4192 Posts
Re: how to view a cookie
Dec 27, 2011 02:33 PM|LINK
If you do not set the cookie's expiration, the cookie is created but it is not stored on the user's hard disk. Instead, the cookie is maintained as part of the user's session information. When the user closes the browser, the cookie is discarded. A non-persistent cookie like this is useful for information that needs to be stored for only a short time or that for security reasons should not be written to disk on the client computer. For example, non-persistent cookies are useful if the user is working on a public computer, where you do not want to write the cookie to disk.
http://msdn.microsoft.com/en-us/library/ms178194.aspx
Pradeep Kr. ...
Participant
1712 Points
294 Posts
Re: how to view a cookie
Dec 27, 2011 03:49 PM|LINK
Cookies are created in system at below location
C:\Documents and Settings\[loginName]\cookies
like if i loggedin in my computer with user name pradeep then cookies will we created at below location in my system.
C:\Documents and Settings\pradeep\cookies
same way you can check cookie at your system.
http://vshelpdesk.blogspot.com/
Please Mark As Answer, which helped you. So that it might be useful for others.
Tualatin
Member
131 Points
172 Posts
Re: how to view a cookie
Dec 29, 2011 12:13 AM|LINK
Thanks Smirnov, I set the cookie to expire now.adddays(1) but still couldn't find the cookie in C:\Documents and Settings\John\Local Settings\Temporary Internet Files. Here is the code below. Steppin through the code I can see that the "add cookie" code is executed.
Any ideas why I still don't see the cookie in that particular folder? That is the folder that comes up when I hit IE8/Tools/Internet Options General Tab/Browsing History Settings button/View files button.
'/// Check to see if the OKS cookie already exists If HttpContext.Current.Request.Cookies("OKS") Is Nothing Then '/// it doesn't exist so create one '/// Write a working cookie to hold all the variables Dim anotherCookie As New HttpCookie("OKS") anotherCookie.Values("Dojo") = "dojoID" anotherCookie.Values("Course") = "courseID" anotherCookie.Values("Family") = "familyID" anotherCookie.Values("Member") = "memberID" anotherCookie.Expires = DateTime.Now.AddDays(1) HttpContext.Current.Request.Cookies.Add(anotherCookie) Else '/// it exists already so let's get the values Dim sDojo As String '= something Dim sCourse As String '= something Dim sFamily As String '= something Dim sMember As String '= something '/// more code End IfTualatin
Member
131 Points
172 Posts
Re: how to view a cookie
Dec 29, 2011 12:18 AM|LINK
Pradeep I don't have a cookies folder, I do have C:\Documents and Settings\John\Local Settings\Temporary Internet Files but my cookies don't appear there - any other ideas?
Tualatin
Member
131 Points
172 Posts
Re: how to view a cookie
Dec 30, 2011 01:54 AM|LINK
Ok, I figured it out with some help. I wasn't using Response. Instead I was using Request. Here is the right way to load a cookies at the class level:
'/// Write a working cookie to hold all the variables Dim anotherCookie As New HttpCookie("OKS") anotherCookie.Values("Dojo") = "dojoID" anotherCookie.Values("Course") = "courseID" anotherCookie.Values("Family") = "familyID" anotherCookie.Values("Member") = "memberID" anotherCookie.Expires = DateTime.Now.AddDays(1) HttpContext.Current.Response.Cookies.Add(anotherCookie)