Skip to content

Commit

Permalink
cookie stuff for adsbexchange
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Apr 1, 2021
1 parent a846585 commit de3d62d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6042,6 +6042,34 @@ function globeRateUpdate() {
if (data.refresh != null)
RefreshInterval = data.refresh;
});
const cookieExp = getCookie('adsbx_sid').split('_')[0];
const ts = new Date().getTime();
if (!cookieExp || cookieExp < ts + 3600*1000)
setCookie('adsbx_sid', ((ts + 2*86400*1000) + '_' + Math.random().toString(36).substring(2, 15)), 2);
}

function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}

function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}


initialize();

0 comments on commit de3d62d

Please sign in to comment.