How to set a cookie in concrete 5?

Permalink
I'm running into all sorts of problems with doing this. I'd like to check a session variable in my block controller and if it exists set a cookie. Then I'd also like to look for the value of a cookie and do some stuff based on it.

It seems like setcookie doesn't work inside of block controllers. I was able to move the code from the block controller to dispatcher.php and put it after the session startup and it worked fine there but when I call it from the block controller the cookie is not set.

What is the proper way to set cookies in concrete 5? Is there a helper or something? Is there some other place in the code where cookies should be set? I've stepped through with the debugger and I can see the setcookie function being run inside of the block controller but the value never gets read back by the browser on subsequent page loads.

hereNT
 
hereNT replied on at Permalink Best Answer Reply
hereNT
It turns out this was because I was trying to call it from within a named block so the on_start was happening after the header and half the page was already rendered instead of before page render like it's supposed to go. I managed to get it working with jquery.cookie.js instead, that worked much better.