[Zope] Re: Checking if cookies enabled

Richard Barrett R.Barrett@ftel.co.uk
Tue, 27 Nov 2001 14:11:01 +0000


At 12:52 24/11/2001 +0100, Lars Heber wrote:
 > Another possibility without using any JavaScript, thus independent from
 > the JS settings of the user is:
 >
 > DTML method cookieTest:
 >
 > <dtml-call "RESPONSE.setCookie('cookiesAllowed', 'yes')">
 > <html><head>
 > <meta http-equiv="refresh" content="0; URL=cookieTestComplete">
 > </head>
 > <body>
 > <a href="cookieTestComplete">Redirecting to cookieTestComplete...</a>
 > <dtml-var standard_html_footer>

Neat. This is much better that relying on Javascript and the user's 
settings for it. Alternatively you could say:

<dtml-call "RESPONSE.setCookie('cookiesAllowed', 'yes', 
path='your-protected-path', domain='your-server')">
<dtml-call "RESPONSE.redirect('whichever-URL-you-want-to-end-up-at', 
status=302)">

The only advantage of this over the original suggestion is that some 
(probably ancient) browsers may not support and correctly interpret the 
META HTTP-EQUIV whereas the HTTP 302 redirect response is unlikely to fail 
on any browser.