Can i have a cookie

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
 
O

One Handed Man \( OHM - Terry Burns \)

cookies have to be enabled on the client browser. Is that true?
Yes, to store a cookie, the browser has to enable this.
If true where can i find that cookie in my pc directories?
Documents And Settings\UserName\Cookies

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.
You may want to close the browser sessions ( all of them ) down after
changing this setting
 
G

Guest

how do i turn off cookies on my browser. it looked as though i could goto
internet options and on the privacy tab set it to block all cookies but even
when i do that the sample program below still says AcceptCookies=1 instead of
0.
 
C

Cor Ligthert

Rodchar,

It is completly depending the browser you are using, when you real want to
know than in your situation I would go to a more browser newsgroup. That
because I think that most of us here are like me not anymore looking too it.
By instance with IE it seems for me that it changes with every security
update from Microsoft.

Just my thought,

Cor
 

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

Similar Threads

check for cookies 1
Cookie Expire 4
Test cookie 1
IE does not accept cookie, how can I troubleshoot it? 2
Cookies Count 2
cookies.... 1
Simple question about cookie: 4
cookie trouble 3

Top