mirror of https://github.com/kiwix/libkiwix.git
Added a TTL parameter to setCookie()
This commit is contained in:
parent
514d6e6514
commit
c85466995d
|
@ -46,10 +46,14 @@
|
|||
return (url);
|
||||
}
|
||||
|
||||
function setCookie(cookieName, cookieValue) {
|
||||
const date = new Date();
|
||||
date.setTime(date.getTime() + oneDayDelta);
|
||||
document.cookie = `${cookieName}=${cookieValue};expires=${date.toUTCString()};sameSite=Strict`;
|
||||
function setCookie(cookieName, cookieValue, ttl) {
|
||||
let exp = "";
|
||||
if ( ttl ) {
|
||||
const date = new Date();
|
||||
date.setTime(date.getTime() + ttl);
|
||||
exp = `expires=${date.toUTCString()};`;
|
||||
}
|
||||
document.cookie = `${cookieName}=${cookieValue};${exp}sameSite=Strict`;
|
||||
}
|
||||
|
||||
function getCookie(cookieName) {
|
||||
|
@ -375,7 +379,7 @@
|
|||
if (filterType) {
|
||||
params.set(filterType, filterValue);
|
||||
window.history.pushState({}, null, `?${params.toString()}`);
|
||||
setCookie(filterCookieName, params.toString());
|
||||
setCookie(filterCookieName, params.toString(), oneDayDelta);
|
||||
}
|
||||
updateFilterColors();
|
||||
updateFeedLink();
|
||||
|
@ -520,7 +524,7 @@
|
|||
}
|
||||
}
|
||||
updateFeedLink();
|
||||
setCookie(filterCookieName, params.toString());
|
||||
setCookie(filterCookieName, params.toString(), oneDayDelta);
|
||||
};
|
||||
|
||||
// required by i18n.js:setUserLanguage()
|
||||
|
|
|
@ -63,7 +63,7 @@ const ResourceCollection resources200Compressible{
|
|||
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.css" },
|
||||
{ STATIC_CONTENT, "/ROOT%23%3F/skin/index.css?cacheid=ac5767d8" },
|
||||
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.js" },
|
||||
{ STATIC_CONTENT, "/ROOT%23%3F/skin/index.js?cacheid=c333bdba" },
|
||||
{ STATIC_CONTENT, "/ROOT%23%3F/skin/index.js?cacheid=2f15ed7d" },
|
||||
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js" },
|
||||
{ STATIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3" },
|
||||
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/isotope.pkgd.min.js" },
|
||||
|
@ -284,7 +284,7 @@ R"EXPECTEDRESULT( href="/ROOT%23%3F/skin/index.css?cacheid=ac5767d8"
|
|||
<script type="text/javascript" src="/ROOT%23%3F/skin/languages.js?cacheid=fe100348" defer></script>
|
||||
<script src="/ROOT%23%3F/skin/isotope.pkgd.min.js?cacheid=2e48d392" defer></script>
|
||||
<script src="/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3"></script>
|
||||
<script type="text/javascript" src="/ROOT%23%3F/skin/index.js?cacheid=c333bdba" defer></script>
|
||||
<script type="text/javascript" src="/ROOT%23%3F/skin/index.js?cacheid=2f15ed7d" defer></script>
|
||||
<img src="/ROOT%23%3F/skin/feed.png?cacheid=56a672b1" class="feedLogo" alt="Library OPDS Feed" aria-label="Library OPDS Feed" title="Library OPDS Feed">
|
||||
)EXPECTEDRESULT"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue