G
Guest
Hey all,
I'm trying to gain more knowledge about state management and I found an MSDN
Help article about cookies. I posted the short sample below. From what I read
in the article if you do the following
Session("MyObj")=value
cookies have to be enabled on the client browser. Is that true?
If true where can i find that cookie in my pc directories?
About the sample: there's 2 .aspx pages with just 1 label on the first page.
This is a test to see if cookies are enabled on a client browser. But no
matter what setting on the privacy tab i pick, i'm always showing that
cookies are enabled. And each time i delete my cookies after i change the
setting to make sure that there are no existing cookies prior to running the
test.
Sub Page_Load()
If Not Page.IsPostBack Then
If Request.QueryString("AcceptsCookies") Is Nothing Then
Response.Cookies("TestCookie").Value = "ok"
Response.Cookies("TestCookie").Expires = _
DateTime.Now.AddMinutes(1)
Response.Redirect("TestForCookies.aspx?redirect=" & _
Server.UrlEncode(Request.Url.ToString))
Else
labelAcceptsCookies.Text = "Accept cookies = " & _
Request.QueryString("AcceptsCookies")
End If
End If
End Sub
Here's the 2nd page code:
Sub Page_Load()
Dim redirect As String = Request.QueryString("redirect")
Dim acceptsCookies As String
' Was the cookie accepted?
If Request.Cookies("TestCookie") Is Nothing Then
' No cookie, so it must not have been accepted
acceptsCookies = 0
Else
acceptsCookies = 1
' Delete test cookie
Response.Cookies("TestCookie").Expires = _
DateTime.Now.AddDays(-1)
End If
Response.Redirect(redirect & "?AcceptsCookies=" & acceptsCookies, _
True)
End Sub
any ideas?
thanks,
rodchar
I'm trying to gain more knowledge about state management and I found an MSDN
Help article about cookies. I posted the short sample below. From what I read
in the article if you do the following
Session("MyObj")=value
cookies have to be enabled on the client browser. Is that true?
If true where can i find that cookie in my pc directories?
About the sample: there's 2 .aspx pages with just 1 label on the first page.
This is a test to see if cookies are enabled on a client browser. But no
matter what setting on the privacy tab i pick, i'm always showing that
cookies are enabled. And each time i delete my cookies after i change the
setting to make sure that there are no existing cookies prior to running the
test.
Sub Page_Load()
If Not Page.IsPostBack Then
If Request.QueryString("AcceptsCookies") Is Nothing Then
Response.Cookies("TestCookie").Value = "ok"
Response.Cookies("TestCookie").Expires = _
DateTime.Now.AddMinutes(1)
Response.Redirect("TestForCookies.aspx?redirect=" & _
Server.UrlEncode(Request.Url.ToString))
Else
labelAcceptsCookies.Text = "Accept cookies = " & _
Request.QueryString("AcceptsCookies")
End If
End If
End Sub
Here's the 2nd page code:
Sub Page_Load()
Dim redirect As String = Request.QueryString("redirect")
Dim acceptsCookies As String
' Was the cookie accepted?
If Request.Cookies("TestCookie") Is Nothing Then
' No cookie, so it must not have been accepted
acceptsCookies = 0
Else
acceptsCookies = 1
' Delete test cookie
Response.Cookies("TestCookie").Expires = _
DateTime.Now.AddDays(-1)
End If
Response.Redirect(redirect & "?AcceptsCookies=" & acceptsCookies, _
True)
End Sub
any ideas?
thanks,
rodchar