[Zope] Name error cookie check

Nico de Boer nico@nfg.nl
29 Mar 2002 10:32:54 +0100


Hai all,

I'm having a problem with a site. I want to check for user agent, and
if the visitor uses MSIE, Netscape or Mozilla set a cookie
'showflash'. This is for the flash site. The other user agents have to
go to the html-site. This is my code:

<dtml-call "REQUEST.set('ua',HTTP_USER_AGENT)">
<dtml-if "(_.string.find(ua,'Mozilla')<0 and _.string.find(ua,'Netscape')<0 and  _.string.find(ua,'MSIE')<0) or showflash">
<dtml-var standard_html_header><dtml-var main><dtml-var standard_html_footer>
<dtml-else>
<dtml-call "RESPONSE.setCookie('showflash','true',path='/')">
<dtml-call "RESPONSE.redirect('/flash/')">
</dtml-if>

But the first time someone visits the site, there is no cookie set. So
I get a name error. Can anyone solve my problem?

Thanks!

Greetz Nico