Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Getting / Setting a value from js into the template

Go to End



Community Member, 224 Posts

21 February 2010 at 3:30pm

Edited: 21/02/2010 3:35pm

I'm not sure about what I need here or how to really ask the question...

I am setting a cookie (sneAlertCookie) to allow a visitor to a second page, but only one time. If they return to this second page, they are brought to another page - this is all working.

I have an alert box on the first page for first time visitors. If they travel to the second page (above) a cookie is set on their computer. If they leave and return to this second page, the system redirects them to the page of my choice. Again all working.

If a visitor comes back to the site on the first page (the one with the alert box), I want to get a value from their cookie and use it on this page to in an IF to turn the alert off.

var value == sneAlertCookie; //from client cookie - does it exist


<% if sneAlertCookie == value %>

How do I get a value from javascript or set in the php file for this page type (AlertPage) ??

Anyone with some great knowledge offer some ideas and help here?

Thank you,