By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,497 Members | 2,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,497 IT Pros & Developers. It's quick & easy.

testing for cookies

P: n/a
I need to test if cookies are enabled in the browser. I disabled cookies in
my browser and rebooted my browser, yet the below code still writes a cookie
and reads it correctly. Am I approaching this correctly?
thanks
<%
Response.Cookies("smcookietest") = ("8")
Response.Cookies("smcookietest").Expires = Date + 2
%>
<%
If Request.Cookies("smcookietest") <> "8" Then
Response.Redirect("error.asp?error=19")
End If
%>
<%=Request.Cookies("smcookietest")%>
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
What you'd need to do is set the cookie, navigate to a new page, then try
and read the cookie. doing it in the same script won't tell you anything
useful.
--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.

"shank" <sh***@tampabay.rr.com> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl...
I need to test if cookies are enabled in the browser. I disabled cookies in
my browser and rebooted my browser, yet the below code still writes a
cookie and reads it correctly. Am I approaching this correctly?
thanks
<%
Response.Cookies("smcookietest") = ("8")
Response.Cookies("smcookietest").Expires = Date + 2
%>
<%
If Request.Cookies("smcookietest") <> "8" Then
Response.Redirect("error.asp?error=19")
End If
%>
<%=Request.Cookies("smcookietest")%>

Jul 22 '05 #2

P: n/a
Thanks. That was the problem. However, is there a way to check for cookies
enabled on the same page? I set sessions on the home page and if the user
has everything disabled in their browser, they don't get set.
thanks

"Jason Brown [MSFT]" <i-******@online.microsoft.com> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
What you'd need to do is set the cookie, navigate to a new page, then try
and read the cookie. doing it in the same script won't tell you anything
useful.
--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.

"shank" <sh***@tampabay.rr.com> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl...
I need to test if cookies are enabled in the browser. I disabled cookies
in my browser and rebooted my browser, yet the below code still writes a
cookie and reads it correctly. Am I approaching this correctly?
thanks
<%
Response.Cookies("smcookietest") = ("8")
Response.Cookies("smcookietest").Expires = Date + 2
%>
<%
If Request.Cookies("smcookietest") <> "8" Then
Response.Redirect("error.asp?error=19")
End If
%>
<%=Request.Cookies("smcookietest")%>


Jul 22 '05 #3

P: n/a
No, You have to have a new request to the server after you set the cookie in
order to determine if the browser sends it back.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"shank" <sh***@tampabay.rr.com> wrote in message
news:e3**************@TK2MSFTNGP12.phx.gbl...
Thanks. That was the problem. However, is there a way to check for cookies
enabled on the same page? I set sessions on the home page and if the user
has everything disabled in their browser, they don't get set.
thanks

"Jason Brown [MSFT]" <i-******@online.microsoft.com> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
What you'd need to do is set the cookie, navigate to a new page, then try and read the cookie. doing it in the same script won't tell you anything
useful.
--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.

"shank" <sh***@tampabay.rr.com> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl...
I need to test if cookies are enabled in the browser. I disabled cookies
in my browser and rebooted my browser, yet the below code still writes a
cookie and reads it correctly. Am I approaching this correctly?
thanks
<%
Response.Cookies("smcookietest") = ("8")
Response.Cookies("smcookietest").Expires = Date + 2
%>
<%
If Request.Cookies("smcookietest") <> "8" Then
Response.Redirect("error.asp?error=19")
End If
%>
<%=Request.Cookies("smcookietest")%>



Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.