rewriting as free software
This commit is contained in:
parent
760422dfd1
commit
ee38b8d25e
@ -1,18 +1,41 @@
|
|||||||
/*
|
/* cookies.js; Deven Blake 2021; Public Domain to extent allowed, see below */
|
||||||
these code snippets copied from
|
|
||||||
https://www.w3schools.com/js/js_cookies.asp
|
|
||||||
used under fair use; for copyright see https://www.w3schools.com/about/about_copyright.asp
|
|
||||||
|
|
||||||
window.setCookie() sets a cookie, window.getCookie() gets a cookie.
|
window.setCookie = function(name, value){
|
||||||
|
var d;
|
||||||
|
d = new Date();
|
||||||
|
/* seconds, minutes, hours, days, years */
|
||||||
|
d.setTime(d.getTime() + 1000 * 60 * 60 * 24 * 365);
|
||||||
|
/* ( == one year in milliseconds) */
|
||||||
|
document.cookie = name + "=" + value + ";" + d.toUTCString() + ";path=/";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Public domain rewrite */
|
||||||
|
/*
|
||||||
|
window.getCookie = function(name){
|
||||||
|
var c;
|
||||||
|
var i;
|
||||||
|
try{
|
||||||
|
c = decodeURIComponent(document.cookie);
|
||||||
|
}catch(URIError){
|
||||||
|
console.log("Could not decode cookie URIComponent (cookies.js: getCookie: URIError)");
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
c = c.split(';');
|
||||||
|
for(i = 0; i < c.length; ++i){
|
||||||
|
while(c[i].charAt(0) == ' ')
|
||||||
|
c[i] = c[i].slice(1);
|
||||||
|
if(c[i].slice(0, name.length + 1) == name + '=')
|
||||||
|
return c[i].substring(name.length, c[i].length);
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
window.setCookie = function(cname, cvalue, exdays) {
|
/*
|
||||||
var d = new Date();
|
this code snippet copied from
|
||||||
d.setTime(d.getTime() + (exdays*24*60*60*1000));
|
https://www.w3schools.com/js/js_cookies.asp
|
||||||
var expires = "expires="+ d.toUTCString();
|
used under fair use; for copyright see https://www.w3schools.com/about/about_copyright.asp
|
||||||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
*/
|
||||||
};
|
|
||||||
|
|
||||||
window.getCookie = function(cname) {
|
window.getCookie = function(cname) {
|
||||||
var name = cname + "=";
|
var name = cname + "=";
|
||||||
var decodedCookie = decodeURIComponent(document.cookie);
|
var decodedCookie = decodeURIComponent(document.cookie);
|
||||||
|
Loading…
Reference in New Issue
Block a user