-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
Now you have cookie time only in nr of days, you could enhance that a little.
The old "days" parameter is renamed to "period".. (it defaults back to the original days).
Now the period can be "4d" or "8h" or "1d4h" or "12" for just 12 days
if (typeof period === "number") {
period = period.toString()+"d"
}
if (typeof period === "string") {
var addtime=0, t, i, reg = /([0-9]{1,3}[d|h])/g, arr = period.match(reg);
for (i=0;i<arr.length;i++) {
t=arr[i].slice(-1);
switch(t) {
case 'h':
addtime += (parseInt(arr[i]) * 60 * 60 * 1000)
break;
case 'd':
default:
addtime += (parseInt(arr[i]) * 24 * 60 * 60 * 1000)
break;
}
}
date.setTime(date.getTime() + addtime);
expires = "; expires=" + date.toUTCString();
}
Metadata
Metadata
Assignees
Labels
No labels