DIGIT-ARC read-only archive · snapshot: July 23, 2026

logout confimation with jquery alert?

2 posts · originally from https://geek.digit.in/community/threads/logout-confimation-with-jquery-alert.140331/

B
bagsfr Original post #1
May 6, 2011 at 3:35 PM
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 at 3:45 PM
No need of jQuery, simple javascript would do this.

Code:
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:
<?php

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

header("Location:homepage.html");

?>