# logout confimation with jquery alert?



## bagsfr (May 6, 2011)

hey all,
i wanna make a confirmation alert box (jquery i suppose) then when triggers when someone click log out. on cancel it stays there but on ok it destory the session and cookies and logout. anyone help me out me wid that?


----------



## krishnandu.sarkar (May 6, 2011)

No need of jQuery, simple javascript would do this.


```
var logout = confirm("Do you really want to Logout?");
if (logout == true)
{
   window.location="*yourplace.com/yourpage.php";
}
```

Now put this under a function say confirmLogout() and call this on onclick event of button.

Now on that PHP page, where you'd redirect destroy the session etc. and whatever you want to do and redirect it to homepage at last.

For eg.

```
<?php

ob_start();
session_start();
session_destroy();

header("Location:homepage.html");

?>
```


----------

