Yo.utils.setCookie
Use this function to set a cookie in your Yottaa application.
Prerequisites
The following command to load the appropriate version of the Rapid+JS Library must precede the use of this function on the page. Specify your own site key:
<script src="https://rapid-cdn.yottaa.com/rapid/lib/sitekey.js"></script>
Syntax
Yo.utils.setCookie ( 'cookieName,' cookieValue', [ 'expirationTime' ] )
Returns
No response
Parameters
Parameter |
Description |
---|---|
cookieName |
String. The name of the cookie. |
cookieValue |
String. The data to be saved in the cookie. Format: Text specified as a string in single quotation marks, or the name of a parameter whose type is string. |
expirationTime |
String. Interval after which the cookie expires, in seconds. Format: Integer |
Examples
This example sets a cookie called customerLoggedIn, with a value of 'true', that expires after 10 hours.
Yo.utils.setCookie('customerLoggedIn', 'true', 36000);
This example sets a cookie called customerBasketItem, with a value of '1', that expires after 20 hours.
Yo.utils.setCookie('customerBasketItem','1', 72000);