Use it like this in the page:
{setCookies days='numDays' cookie1="value1" cookie2="value2"}
Required Parameters:
days='5' this sets the expiration date of the cookie.
This will work with versions of CMSMS that process the body before the head of the document. (Cookies must be sent before the . So if you have it set up that CMSMS processes the head before the body, where your {setCookies} tag is, then it will not work.)
You can have as many cookie="value" pairs as you want, with any name you want, as long as each cookie name is unique.
Here's the code:
Code: Select all
if (isset($params)) {
if (isset($params['days'])) {
$expire=time() + ($params['days']*86400);
foreach ($params as $name => $value) {
if ($name!='days') {
setcookie($name,$value,$expire);
unset($value);
}
}
return;
}
else {
print('Error: setCookies parameter "days" is required');
}
}
else {
print('Error: setCookies requires parameters.');
return;
}