Advertisement
2002ASP Internet/ Browsers/ HTML #8040

Detect if cookies are enabled

When you work with cookies, you always run into paranoid types who disable their cookies. If you don't detect and deal with them, your code may not work. This code detects the user's cookie settings using the ASP Session object. Unlike some other implementations, it requires only one script page.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
<%@ Language=VBScript %>
<%option explicit
if (Request("lngSessionId")="") then
	'first time through
	
	'redirect back to ourselves
	Response.Redirect "CookieCheck.asp?lngSessionId=" & Session.SessionID
else
	'second time through
dim lngSessionId	
	lngSessionId = Request("lngSessionId")
	If lngSessionId = Session.SessionID then
		Response.Write "User has cookies turned ON."
	Else
		Response.Write "User is paranoid and has cookies turned OFF."
	End If
end if
%>
Original Comments (3)
Recovered from Wayback Machine