Forums
This topic is locked
Are cookies enabled?
Posted 10 Jan 2003 17:31:44
1
has voted
10 Jan 2003 17:31:44 Dave Clarke posted:
HiHow can I detect if a user has cookies enabled and redirect if they haven't??
Thanks
Dave
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Replies
Replied 11 Jan 2003 17:33:45
11 Jan 2003 17:33:45 asp asp replied:
Hey! here ya go!
1st page called cookietest.asp put this in it.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
response.cookies("enabled"
="1"
response.redirect("cookietest2.asp"
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
</body>
</html>
---------------------------
now we check on the next page to get a result,
this page is called cookietest2.asp
place this in it,
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
if request.cookies("enabled"
="1" then
response.write("cookies are enabled"
else
<!-- response.write("cookies are not enabled"
-->
response.redirect("www.apple.com")
end if
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
</body>
</html>
thats it! of course you should change the redirect URL, and also if you wish to let the user know that they dont have cookies enable then simply UNQUOTE the <!-- response.write("cookies are not enabled"
--> make it just response.write("cookies are not enabled"
thats it! works like a charm!!
1st page called cookietest.asp put this in it.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
response.cookies("enabled"

response.redirect("cookietest2.asp"

%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
</body>
</html>
---------------------------
now we check on the next page to get a result,
this page is called cookietest2.asp
place this in it,
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
if request.cookies("enabled"

response.write("cookies are enabled"

else
<!-- response.write("cookies are not enabled"

response.redirect("www.apple.com")
end if
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
</body>
</html>
thats it! of course you should change the redirect URL, and also if you wish to let the user know that they dont have cookies enable then simply UNQUOTE the <!-- response.write("cookies are not enabled"


Replied 11 Jan 2003 19:55:41
11 Jan 2003 19:55:41 Dave Clarke replied:
Thanks asp.
So basically we are just writing a cookie then reading it back?
Can I put both the response.cookie and the request.cookie on the same page?
Also am I right in saying that if cookies are enabled then session cookies are also enabled so I don't have to check for them?
Thanks
Dave
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
So basically we are just writing a cookie then reading it back?
Can I put both the response.cookie and the request.cookie on the same page?
Also am I right in saying that if cookies are enabled then session cookies are also enabled so I don't have to check for them?
Thanks
Dave
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Replied 11 Jan 2003 21:44:35
11 Jan 2003 21:44:35 Dave Clarke replied:
hi, me again
well i've done that and what happens is the response.write comes up saying cookies are enabled even tho i've turned them off but the little eye & no entry icon comes up saying they are blocked.
The redirect doesn't happen.
maybe it's an IE6 thing??
any more ideas??
Dave
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
well i've done that and what happens is the response.write comes up saying cookies are enabled even tho i've turned them off but the little eye & no entry icon comes up saying they are blocked.
The redirect doesn't happen.
maybe it's an IE6 thing??
any more ideas??
Dave
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Replied 11 Jan 2003 23:34:19
11 Jan 2003 23:34:19 asp asp replied:
make sure you go to tools/security and ADVANCED/ DISABLE ALLOW COOKIES AND ALLOW COOKIES PER SEESION, both must be off, this worked fine for me in explorer 5 and should be the same in 6, and yes you should be able to use them on the same page!! good luck!