Javascript delete cookie before reload or redirect -


i need delete cookie , then redirect. cookie doesn't deleted until redirect processed. problem if cookie still exists @ time redirect executed, redirect intercepted , sent page other 1 intended. (weird, know; long story)

is possible trick browser , force deletion of cookie before redirect?

jquery('div#paneld').click(function(){     document.cookie = 'sharedsession=; expires=thu, 01 jan 1970 00:00:01 gmt; domain=.example.com; path=/';     window.location.href = "www.example.com/x"; }); 

i discovered if perform ajax call anything, qualifies refresh purposed of deleting cookies.

var fakeajax = new xmlhttprequest(); var = fakeajax.responsetext; fakeajax.open("get","ajax_info.txt",false);  // file doesn't exist fakeajax.send(); 

note "false" in open line. asynchronous has set false (or other delay) allow time new info come , cookie deleted.

update: ie doesn't requesting responsetext file doesn't exist remove line completely. other browsers seem fine or without it.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -