As i doing research i know most of them are suggesting use
<body onbeforeunload="beforeUnload" onunload="unload">

But i trying to do some sample, is this can't work it.
Could you guys provide a simplest example to me ?
In fact, i gonna to delete the Cookies value whenever they are trying to close web tab or shifting to non-of-my designed web page.

Thanks for in advance


Maybe try something like this:

window.onbeforeunload = function() {
    //Clear Your Cookies Here
    deleteCookie('YOUR COOKIE NAME HERE');
    return 'Your Cookies Have Been Cleared!';

function deleteCookie(c_name) {
    document.cookie = encodeURIComponent(c_name) + "=deleted; expires=" + new Date(0).toUTCString();

The cookie is still remain un-remove. :(

function deleteCookies() {
    document.cookie = "Username=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/";

Soluton solved because left out the path=/ at the end of the cookie sentence.
Thanks for helping me folks.