Hello friends I need to auto logout my all the open tabs when logout from one of them
I hava tried following code from this previous discussion link How to handle the user logout in browser multiple tab?
Code:-
<script type="text/javascript">
function readCookie(name) {
var nameEQ = escape(name) + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) === 0) return unescape(c.substring(nameEQ.length, c.length));
}
return null;
}
window.setInterval(function() {
if(readCookie('loggedout')==1) {
window.location.assign('loggedout.html');
//Or whatever else you want!
}
},1000);
</script>
I hava place this code footer of all the pages than I set cookies in logout.php by setcookie('loggedout',1) function and unset cookie at top of the login page
but the strange things are it works well for some pages and in case it works next time if I try login then login successfully but after 1 second it logouts me automatically
please let me know whats the problem with this code and any one of you have better regarding this topic please help me