set cookie properly
parent
00ae355cf1
commit
68e84b07c6
|
|
@ -31,6 +31,14 @@ function httpPostAsync(theUrl, data, callback, failCallback) {
|
||||||
xmlHttp.send(JSON.stringify(data));
|
xmlHttp.send(JSON.stringify(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setCookie(cname, cvalue, exdays) {
|
||||||
|
const d = new Date();
|
||||||
|
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
||||||
|
let expires = "expires=" + d.toUTCString();
|
||||||
|
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function getCookie(cname) {
|
function getCookie(cname) {
|
||||||
let name = cname + "=";
|
let name = cname + "=";
|
||||||
let decodedCookie = decodeURIComponent(document.cookie);
|
let decodedCookie = decodeURIComponent(document.cookie);
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@
|
||||||
console.log(resp);
|
console.log(resp);
|
||||||
let respData = JSON.parse(resp);
|
let respData = JSON.parse(resp);
|
||||||
if (respData['hw_id'] != '') {
|
if (respData['hw_id'] != '') {
|
||||||
document.cookie = "hw_id=" + respData['hw_id'] + "; SameSite=None; Secure";
|
setCookie('hw_id', respData['hw_id'], 60);
|
||||||
window.location.href = "/";
|
window.location.href = "/";
|
||||||
}
|
}
|
||||||
}, (status) => {
|
}, (status) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue