Place this at the top of every page, if a cookie isn't there, it then send some script and a noscript tag, along with a cookie setting. When the script runs, it will in essence re-run the same page. If it shows the noscript data, it will go to another page with the noscript error. When it reloads the page, add something to the querystring, and then you can check for the cookie at the same time.
If you have form information that comes from another site that you wish to preserve, then put the form in all hidden fields, and submit it as part of the script.
<%
If Not (Request.Cookies("cookietest") = "true") Then
If Request.Querystring("scripttest") = "true" Then
Response.Redirect "nocookie.asp" 'Has scripting, no cookie
Else 'no tests yet, send tests
Response.Cookies("cookietest") = "true"
%><html><head></head><body><script>
document.write("Testing browser capabilities...")
location.replace(location.href +
((location.href.indexOf("?") >= 0)?"&":"?") +
"scripttest=true")
</script>
<noscript>
This site requires scripting,
<a href="noscripting.asp">Click Here</a>
for more information.
</noscript>
</body></html>
<%'noscripting.asp, still check for the cookie, and give an error
for script & cookie, if no cookie.
End If
Response.End
End If
%>
Created by Michael J. Ryan for the ASP discussion list.