Click to See Complete Forum and Search --> : Cookie detection


Motabobo
06-18-2003, 12:58 PM
Hi again !

I've written a script that detects if cookies are enabled or not. The only problem is that i need 3 pages (haven't been able to make it work with only 2 (preferably 1)) page(s).

For some reason, using the cookie ServerVariable will always return true so i had to write a cookie and try to read it.

Is it possible to make it work (on the very first page of the website) with only 1 or 2 pages ? I must have missed something...

In default.asp :

<%
if Request("cookies") = "" then
Response.redirect "test.asp"
end if

if Request("cookies") = "non" then
Response.Write("Disabled")
else
Response.Write("Enabled")
end if
%>


In test.asp :

<%
If Request.Cookies("TestCookie").HasKeys Then
Response.redirect "default.asp?cookies=oui"
Else

Response.Cookies("TestCookie")("TestValue") = 1
Response.Cookies("TestCookie").Expires = #december 31, 2005#
Response.Cookies("TestCookie").Path = "/"
Response.Write "<meta http-equiv='refresh' content='0; url=test2.asp'>"

End If
%>


In test2.asp :

<%
If Request.Cookies("TestCookie").HasKeys Then
If Request.Cookies("TestCookie")("TestValue") = 1 then
Response.Redirect "default.asp?cookies=oui"
Else
Response.Redirect "default.asp?cookies=non"
End if
Else
Response.Redirect "default.asp?cookies=non"
End If
%>


Thanks :)

Motabobo
06-18-2003, 10:25 PM
Thanks :D