diff --git a/velconnect/static/js/util.js b/velconnect/static/js/util.js index fda7514..8580903 100644 --- a/velconnect/static/js/util.js +++ b/velconnect/static/js/util.js @@ -31,6 +31,14 @@ function httpPostAsync(theUrl, data, callback, failCallback) { 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) { let name = cname + "="; let decodedCookie = decodeURIComponent(document.cookie); diff --git a/velconnect/templates/pair.jinja b/velconnect/templates/pair.jinja index 1655050..9efee2d 100644 --- a/velconnect/templates/pair.jinja +++ b/velconnect/templates/pair.jinja @@ -78,7 +78,7 @@ console.log(resp); let respData = JSON.parse(resp); if (respData['hw_id'] != '') { - document.cookie = "hw_id=" + respData['hw_id'] + "; SameSite=None; Secure"; + setCookie('hw_id', respData['hw_id'], 60); window.location.href = "/"; } }, (status) => {