Legacy Documentation
You are using the documentation for version 4.3.8. Go here for the latest version.
Cookie Service¶
New in version 4.3.8.
The Cookie service provides a convenient way to set and read cryptographically-signed cookies. Setting cryptographically-signed cookies helps ensure the cookies you set are not altered client-side.
Simple Examples¶
Set a cookie:
ee('Cookie')->setSignedCookie('my_cookie_name', $data);
Retriving cookie data:
ee('Cookie')->getSignedCookie('my_cookie_name');
Cookie Methods¶
-
class
EllisLab\ExpressionEngine\Service\Cookie\
Cookie
¶
-
EllisLab\ExpressionEngine\Service\Cookie\Cookie::
getSignedCookie
($cookie_name, $xss_clean = FALSE)¶ Gets cryptographically-signed cookie data by name.
Parameters: - $cookie_name (string) – Cookie name
- $xss_clean (boolean) – Clean the data for XSS or not
Returns: Cookie data, or FALSE if cookie not found or verified
Return type: mixed
-
EllisLab\ExpressionEngine\Service\Cookie\Cookie::
setSignedCookie
($cookie_name, $cookie_data, $expire = NULL)¶ Set cryptographically-signed cookies.
Parameters: - $cookie_name (string) – Cookie name
- $cookie_data (string) – Cookie data
- $expire (int) – Cookie expiration in seconds
Return type: void