Sets a cookie value in a browser.

Used to retain session information or information about anonymous users.

An expiration date can also be passed to make the cookie expire at a specified time.


Do not store secure data in a cookie. You should limit the use of cookies due to the risk of malicious users setting cookies on your site.

Type and Usage


This function can take three parameters:

  • The first parameter is the name of the cookie.

  • The second parameter is the value to be set.

  • The third optional parameter is an expiration indicator specifying when the cookie will expire.


The following example sets the cookie myCounter in the user's browser and increments the value when the user visits the page. The cookie will expire in one day.

<$if not myCounter$>
Num times loaded: <$myCounter$>
<$setCookie("myCounter", myCounter+1, dateCurrent(1))$>

See Also