xenforo.js contains this function:
I am using the following syntax in <script type="text/javascript"> tags in a template:
$.setCookie('name', 'value')
This successfully sets a cookie called "name" with a value of "value". By default, as no expiry time is specified, it creates a session cookie.
Can anyone help me with the correct syntax to specify an expiry date?
Thanks
Code:
/**
* Sets a cookie.
*
* @param string cookie name (escaped)
* @param mixed cookie value
* @param string cookie expiry date
*
* @return mixed cookie value
*/
setCookie: function(name, value, expires)
{
console.log('Set cookie %s=%s', name, value);
document.cookie = XenForo._cookieConfig.prefix + name + '=' + encodeURIComponent(value)
+ (expires === undefined ? '' : ';expires=' + expires.toGMTString())
+ (XenForo._cookieConfig.path ? ';path=' + XenForo._cookieConfig.path : '')
+ (XenForo._cookieConfig.domain ? ';domain=' + XenForo._cookieConfig.domain : '');
return value;
},
I am using the following syntax in <script type="text/javascript"> tags in a template:
$.setCookie('name', 'value')
This successfully sets a cookie called "name" with a value of "value". By default, as no expiry time is specified, it creates a session cookie.
Can anyone help me with the correct syntax to specify an expiry date?
Thanks