-1

I opened the chrome dev tool and from application Cookies, I changed the Cookie Expires / Max-Age to previous time then current time.

My question is when i change the Expires / Max-Age, its instantly reflecting and logged-out from website.

if logout functionality implemented at code level then how can we listen for cookie change and how can we achieve this functionality?

Jaisa Ram
  • 1,687
  • 14
  • 21

1 Answers1

0

I got it from What do browsers do with expired cookies?

and from

var checkCookie = function() {

var lastCookie = document.cookie; // 'static' memory between function calls

return function() {

    var currentCookie = document.cookie;

    if (currentCookie != lastCookie) {

        // something useful like parse cookie, run a callback fn, etc.

        lastCookie = currentCookie; // store latest cookie

    }
};
}();

window.setInterval(checkCookie, 100); // run every 100 ms
Jaisa Ram
  • 1,687
  • 14
  • 21