You can use the below helper method to create a cookie.
So as an example, to create a cookie that stores the name of a visitor, you can call the helper method like below:
helper.createCookie('username', 'John Doe', 7);
To create a session cookie, don't pass any value for days. So you will be calling the helper method like below:
helper.createCookie('username', 'John Doe');
After executing the code above, the name of the cookie generated is
LSKey[c]username
. The name of the cookie is prefixed with LSKey[<c>]
where c
is the namespace. So to retrieve the value of this cookie, use the below code:So as an example, to retrieve the cookie value, you can call the helper method like below:
helper.getCookie('username');
Check the link in the references section to check how to delete the cookie.
References: https://www.sitepoint.com/how-to-deal-with-cookies-in-javascript/