Page 1 of 1

Can i set/read cookies with Smarty

Posted: Fri Sep 23, 2022 1:40 pm
by johnboyuk1
Hi

I need to be able to set cookies and check for the existence of the cookie - simply to disable a pop-up box from a page if the visitor has been there before. Can I do this with Smarty from within my page template? If not ... how do I use php within a page? Basically I need this process....

1. A certain page on my site sets a cookie

2. Another page on my site checks for existence of cookie and outputs HTML depending on whether cookie exists, so this process

check for cookie
if cookie exists, display this html
<xxxxxx>
If cookie doesn't exist, display this html
<yyyyy>

Can anyone point me in the right direction?

Re: Can i set/read cookies with Smarty

Posted: Fri Sep 23, 2022 2:49 pm
by DIGI3
Try this tutorial: https://cmscanbesimple.org/blog/set-rea ... ug-cookies

You might also want to look at the jquery cookie method linked at the top of the article (for EU consent, but easily adapted) as another option.

Re: Can i set/read cookies with Smarty

Posted: Fri Sep 23, 2022 3:49 pm
by johnboyuk1
Thanks for this - looks useful, will check it out