Nico de Boer writes:
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? Several alternatives:
* <dtml-unless showflash><dtml-call "REQUEST.set('showflash',0)"></dtml-unless> * "(_.has_key('showflash') and showflash)" rather than "showflash" alone * ... Dieter