[Zope] Checking if cookies enabled

Richard Barrett R.Barrett@ftel.co.uk
Thu, 22 Nov 2001 17:49:04 +0000


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 &lt; and &gt; to avoid misinterpretation of the HTML by MUAs):

&lt;html&gt;
&lt;head&gt;
&lt;SCRIPT LANGUAGE="Javascript"&gt;
function rload() {
     location="./cookietest.html";
}
&lt;/SCRIPT&gt;
&lt;/head&gt;
&lt;body onload="rload()"&gt;
&lt;p&gt;
You appear to have Javascript disabled, please &lt;a 
href="./cookietest.html"&gt;click here&lt;/a&gt; to confirm.
&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;

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 
>&lt; and &gt; to avoid misinterpretation of the HTML by MUAs) :
>
>&lt;html&gt;
>&lt;head&gt;
>&lt;/head&gt;
>&lt;SCRIPT LANGUAGE="Javascript"&gt;
>&lt;!--
>     location="./cookietest.html";
>--&gt;
>&lt;/SCRIPT&gt;
>&lt;p&gt;
>You appear to have Javascript disabled, please &lt;a 
>href="./cookietest.html"&gt;click here&lt;/a&gt; to confirm.
>&lt;/p&gt;
>&lt;/body&gt;
>&lt;/html&gt;
>
>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 )