- You want to set a default language or region for both a logged In and anonymous user.
- You want to show a survey pop-up on a page only once for a limited amount of time even for anonymous users
- You want to store some data that is user specific but not critical and its ok to loose.
You will simple use something like these to set cookies and their equivalent to even get cookies :
setrawcookie('my-cookie', 'truevalue', 0, '/');
$_COOKIE['my-cookie'] = 'truevalue';
$cookie = new Cookie('my-cookie', 'truevalue');
Now, these will work perfectly fine in you local or any environment other than Pantheon.
Now, why does it not work in Pantheon and how can you make it work :
- Pantheon Edge server is used as a CDN to serve pages, the edge server does not recognise a cookie and to read it unless its in a specified format.
- To make it work Prefix the cookie name with the 7 capital letters
STYXKEY_ and followed by your given name.
STYXKEY_my-cookie', 'truevalue', 0, '/');