how get cookies allowed, those that are shown in the "lock" of the browser?
I get a redirect in my page and I need to get a certain SESSION_ID that is passed through certain layers of the API…
Several articles and answers show how to get it from the browser’s storage but this type of cookie is not saved there… An example image below:
https://i.stack.imgur.com/3pjcP.png
>Solution :
read this
Read a Cookie with JavaScript
With JavaScript, cookies can be read like this:
let x = document.cookie;
Some nice functions
Get a Cookie
function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i <ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
Set a Cookie
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=/";
}