please check the following two images:
The logic I want to achieve is the following: We have a web portal in which a user can simulate another user. Now when the user ends his session and starts the browser again, the simulation should be stopped and the user logged out.
To achieve that I set two cookies on login, one cookie with an expiry date of +99 days and another cookie without the expires attribute.
In IE11 the expires column is completely empty, I don't know why. But still when I close the window and end the session, the cookie is still present and my logic doesn't work.
checkSimulationCookieAndLogOut() {
// Checks for cookie if a user is simulated and logs out
let self = this;
let sessionCookie = self.globalFunctions.getCookie('user-is-simulated-session-cookie');
let userSimulationCookie = self.globalFunctions.getCookie('user-is-simulated');
if(!sessionCookie && userSimulationCookie) {
//self.globalFunctions.automaticLogoutAndRedirect();
self.globalFunctions.deleteCookie('user-is-simulated');
console.log('test');
}
}
The cookies are set like this:
setCookie(name,value,days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
self.globalFunctions.setCookie('user-is-simulated-session-cookie', 'true');
self.globalFunctions.setCookie('user-is-simulated', 'true', 99);
The self.globalfunctions
is just a class holding some functions which are shared throughout the application.
Does anyone know what I can do differently or where I'm doing something wrong?
from Session Cookie has wrong behaviour in IE11?
No comments:
Post a Comment