How does one check if a user has disabled cookies on his browser? -- Ed Goppelt
At 11:02 22/11/2001 -0500, Edmund Goppelt wrote:
How does one check if a user has disabled cookies on his browser?
--
Ed Goppelt
You cannot interrogate a browser to determine if it accepts and processes HTTP Cookie headers; HTTP only lets servers respond to browser requests. However, judicious use of Javascript can help you. Send a response which has the Cookie setting header in it which when received immediately gets the browser to reload another of your URLs where you can test if the browser has included the cookie. For instance if your page, say setcookie.html, contained the following HTML (note < and > translated to < and > to avoid misinterpretation of the HTML by MUAs) : <html> <head> </head> <SCRIPT LANGUAGE="Javascript"> <!-- location="./cookietest.html"; --> </SCRIPT> <p> You appear to have Javascript disabled, please <a href="./cookietest.html">click here</a> to confirm. </p> </body> </html> The browser should immediately request the second page, cookietest.html, and you should be able to test for the presence of the Cookie. If it doesn't show up then you can assume Cookies are either disabled in or not supported by the browser and you can respond as appropriate to the user. Of course, this assumes that the user hasn't also disabled Javascript, in which case you'll have to rely on them clicking on the link to request the second page and complete the test.
Soryy, but the example HTML in my original post was a little tacky and while it worked with IE, I found Netscape didn't like it. The revised HTML below appears to work with IE, Netscape and Opera (note < and > translated to < and > to avoid misinterpretation of the HTML by MUAs): <html> <head> <SCRIPT LANGUAGE="Javascript"> function rload() { location="./cookietest.html"; } </SCRIPT> </head> <body onload="rload()"> <p> You appear to have Javascript disabled, please <a href="./cookietest.html">click here</a> to confirm. </p> </body> </html> At 17:18 22/11/2001 +0000, Richard Barrett wrote:
At 11:02 22/11/2001 -0500, Edmund Goppelt wrote:
How does one check if a user has disabled cookies on his browser?
--
Ed Goppelt
You cannot interrogate a browser to determine if it accepts and processes HTTP Cookie headers; HTTP only lets servers respond to browser requests.
However, judicious use of Javascript can help you. Send a response which has the Cookie setting header in it which when received immediately gets the browser to reload another of your URLs where you can test if the browser has included the cookie. For instance if your page, say setcookie.html, contained the following HTML (note < and > translated to < and > to avoid misinterpretation of the HTML by MUAs) :
<html> <head> </head> <SCRIPT LANGUAGE="Javascript"> <!-- location="./cookietest.html"; --> </SCRIPT> <p> You appear to have Javascript disabled, please <a href="./cookietest.html">click here</a> to confirm. </p> </body> </html>
The browser should immediately request the second page, cookietest.html, and you should be able to test for the presence of the Cookie. If it doesn't show up then you can assume Cookies are either disabled in or not supported by the browser and you can respond as appropriate to the user.
Of course, this assumes that the user hasn't also disabled Javascript, in which case you'll have to rely on them clicking on the link to request the second page and complete the test.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Dieter Maurer -
Edmund Goppelt -
Richard Barrett