Can i set/read cookies with Smarty

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
johnboyuk1
Forum Members
Forum Members
Posts: 192
Joined: Mon Nov 26, 2018 3:09 pm

Can i set/read cookies with Smarty

Post 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?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1606
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Can i set/read cookies with Smarty

Post 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.
Not getting the answer you need? CMSMS support options
johnboyuk1
Forum Members
Forum Members
Posts: 192
Joined: Mon Nov 26, 2018 3:09 pm

Re: Can i set/read cookies with Smarty

Post by johnboyuk1 »

Thanks for this - looks useful, will check it out
Post Reply

Return to “CMSMS Core”