var getCookies function var pairs document cookie split var cookies fo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var getCookies = function() {
var pairs = document.cookie.split(;);
var cookies = {};
for (var i = 0; i < pairs.length; i++){
var pair = pairs[i].split(=);
cookies[(pair[0]+‘’).trim()] = unescape(pair[1]);
}
return cookies;
};
var setCookie = function(cname, cvalue, exdays, domain) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = expires= + d.toUTCString();
document.cookie = cname + = + cvalue + ; + expires + ;domain= + domain;
};
var setPaddleCookies = function() {
var cookies = getCookies();
var domain = . + window.location.hostname;
Object.keys(cookies).forEach(function(cookieName) {
if (cookieName.startsWith(paddlejs_)) {
setCookie(cookieName, cookies[cookieName], 30, domain);
}
});
};
window.onload = function() {
setPaddleCookies();
};