javascript: change Cookie.put to take expiry in seconds.
This commit is contained in:
@@ -3,14 +3,14 @@ import Cookie from './cookie'
|
||||
$(function() {
|
||||
$("#hide-upgrade-account-notice").on("click.danbooru", function(e) {
|
||||
$("#upgrade-account-notice").hide();
|
||||
Cookie.put('hide_upgrade_account_notice', '1', 7);
|
||||
Cookie.put('hide_upgrade_account_notice', '1', 7 * 24 * 60 * 60);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$("#hide-promotion-notice").on("click.danbooru", function(e) {
|
||||
$("#promotion-notice").hide();
|
||||
Cookie.put("hide_promotion_notice", "1", 1);
|
||||
Cookie.put("hide_upgrade_account_notice", "1", 1);
|
||||
Cookie.put("hide_promotion_notice", "1", 1 * 24 * 60 * 60);
|
||||
Cookie.put("hide_upgrade_account_notice", "1", 1 * 24 * 60 * 60);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ $(function() {
|
||||
|
||||
$("#hide-verify-account-notice").on("click.danbooru", function(e) {
|
||||
$("#verify-account-notice").hide();
|
||||
Cookie.put('hide_verify_account_notice', '1', 3);
|
||||
Cookie.put('hide_verify_account_notice', '1', 3 * 24 * 60 * 60);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
let Cookie = {};
|
||||
|
||||
Cookie.put = function(name, value, max_age_in_days = 365 * 20) {
|
||||
Cookie.put = function(name, value, max_age_in_seconds = 60 * 60 * 24 * 365 * 20) {
|
||||
let cookie = `${name}=${encodeURIComponent(value)}; Path=/; SameSite=Lax;`;
|
||||
|
||||
if (max_age_in_days) {
|
||||
cookie += ` Max-Age=${max_age_in_days * 24 * 60 * 60};`
|
||||
if (max_age_in_seconds) {
|
||||
cookie += ` Max-Age=${max_age_in_seconds};`
|
||||
}
|
||||
|
||||
if (location.protocol === "https:") {
|
||||
|
||||
Reference in New Issue
Block a user