setcookie
Cookies are a great way to remember visitors, and to store variables from page to page.
[setcookie name=cookieName&value=cookieValue&expires=expireDate&path=/&domain=yourdomain.com]
Using [setcookie] tag in a template causes the remote browser to create or replace a cookie of that name in its local list of cookies. Use [getcookie] or [listcookies] later to retrieve that value from the remote browser.Parameters
Parameter | Description |
---|---|
name | The name of the cookie |
value | The value to be saved in the cookie |
expires | The expiry date in the format: Wednesday, 09-Nov-2022 23:12:40 GMT |
path | The default value for path, '/', will allow any template on the website to access the cookie. You can confine a cookie to a specific directory. For instance, if you specify a path value of '/admin/', then only templates within the '/admin' directory can access the cookie. |
domain | The domain must be the domain from which the cookie is being set, otherwise the browser will not provide the cookie information. Setting the domain parameter limits which domain may access the cookie. If you specify 'www.yourdomain.com', then only templates within that domain can access the cookie. Specifying just 'yourdomain.com' for the domain, will allow templates from 'www.yourdomain.com', 'secure.yourdomain.com', or 'whatever.yourdomain.com' to access the cookie. |
New [setcookie] parameters (from WebDNA 8.5)
Parameter | Description |
---|---|
HttpOnly | (optional) HttpOnly should be T, just like Secure. It adds "httponly" to the cookie, and treats everything else as a F. |
MaxAge | MaxAge sets the time in seconds for when a cookie will be deleted ie MaxAge=30 will expire the cookie in 30 seconds. MaxAge is set in the cookie as "max-age" |
RAW | RAW lets you add anything you want to the cookie. You can use it conjunction with the other parameters or in place of them. You must still specify a name and value. Separate multiple raw parameters with a semi-colon and a space. |
Example secure cookie code:
[setcookie name=cookieName&value=cookieValue&HttpOnly=T&RAW=domain=example.com; secure]
or
[setcookie name=cookieName&value=cookieValue&RAW=domain=example.com; secure; HttpOnly]