testing for cookies

S

shank

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")%>
 
J

Jason Brown [MSFT]

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.
 
S

shank

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
 
M

Mark Schupp

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
 

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


Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top