Set cookie expiration date

This commit is contained in:
Mattias Erming 2014-09-22 02:58:42 -07:00
parent 2fd5f293f0
commit 85988168c8
2 changed files with 25 additions and 4 deletions

View File

@ -126,7 +126,12 @@ $(function() {
} }
if (data.token) { if (data.token) {
$.cookie("token", data.token); $.cookie(
"token",
data.token, {
expires: expire(30)
}
);
} }
$("body").removeClass("signed-out"); $("body").removeClass("signed-out");
@ -291,7 +296,12 @@ $(function() {
var self = $(this); var self = $(this);
var name = self.attr("name"); var name = self.attr("name");
options[name] = self.prop("checked"); options[name] = self.prop("checked");
$.cookie("settings", options); $.cookie(
"settings",
options, {
expires: expire(365)
}
);
if ([ if ([
"join", "join",
"mode", "mode",
@ -575,7 +585,12 @@ $(function() {
} }
}); });
if (values.user) { if (values.user) {
$.cookie("user", values.user); $.cookie(
"user",
values.user, {
expires: expire(30)
}
);
} }
socket.emit( socket.emit(
event, values event, values
@ -654,6 +669,12 @@ $(function() {
location.reload(); location.reload();
} }
function expire(days) {
var date = new Date();
date.setTime(date.getTime() + ((3600 * 1000 * 24) * days));
return date;
}
document.addEventListener( document.addEventListener(
"visibilitychange", "visibilitychange",
function() { function() {

View File

@ -1,7 +1,7 @@
{ {
"name": "shout", "name": "shout",
"description": "A web IRC client", "description": "A web IRC client",
"version": "0.32.2", "version": "0.32.3",
"author": "Mattias Erming", "author": "Mattias Erming",
"preferGlobal": true, "preferGlobal": true,
"bin": { "bin": {