|> Home > Documentation > Latest documentation > Interchange tags > set-cookie|
Tag usage example
or similarly with positional parameters:
This tag sets one or more browser cookies with your specified name, value, expiration date and other parameters, as required. Interchange will set more than one cookie more than one is needed to ensure that the cookie is visible from all Catalog URI path aliases and CookieDomains.
If you need access to the cookie from outside of your Interchangewebsite, then you can also set the domain(s) and URI path(s) for which the cookie will be valid. If you need the cookie to be valid only within your Interchange-driven, and the domains specified by the CookieDomain directive, then you should not specify "domain" and "path" values of your own.
If there is more than one value in the "domain" or "path" (or the associated defaults, specified using the CookieDomain and Catalog directives), then one cookie will be created for each domain and path value combination. This ensures that the cookie will be visible, regardless of the method the visitor uses to return to your website.
This is the name of the cookie. The same name must be used when reading the cookie later, with [read-cookie], or whatever.
The specified value will be stored in the named cookie.
Session cookies are only valid during a browser session, and are automatically rendered invalid (usually deleted) as soon as the user closes the browser.
Persistent cookies outlive browser sessions, but cannot live forever. If you want your cookie to be persistent then you must specify an expiration date. You may set a persistent cookie's expiration date using either of the following two methods:
You may specify any future date/time using the following format:
Relative date/time offset
You may specify an expiration date/time in terms of an offset from the current date and time. The date must take the form of a number, followed by one of "seconds", "minutes", "hours", "days" or "weeks". For example: "7 days", " 4 weeks" or "60 minutes" etc.
You can also use the [time] tag, in conjunction with the [set-cookie], tag to set the expiration date to an absolute or relative date. For example:
The adjustment of "+2160", in the example above, specifies that the cookie's expiration should be "2160 hours" (or "90 days") after the current date. The time format tokens, use in the above example, are listed and explained on this page.
The (space separated) value(s) you specify, using this parameter, will override the default domain(s), listed using the CookieDomain local configuration directive.
You might want to set this if you need to access the cookie from outside of the Interchange-driven website, but it is usually better to use the CookieDomain directive instead.
The default is to use your website's domain or all of the values declared using the CookieDomain local configuration directive.
The (space separated) value(s) you specify, using this parameter, will override the default URI path(s) configured using the Catalog global configuration directive.