0

I need to remove a cookie on browser close event. I am trying to write the following code

window.onunload = function () {
    document.cookie = "empIdDialIntg=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
}

This works fine.But I want to remove the cookie only on browser close event(when clicked on X) not on unload. So if any new site is opened on the same tab,it should persist my cookie value.But with unload my cookie value is removed if i paste new site on the same tab.

Is there any such event in javascript ?

Thanks in advance

Santosh
  • 2,355
  • 10
  • 41
  • 64

0 Answers0