• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

log out confirmation

Hello, I want a javascript that will give the user promt to confirm if he want to log out

here is the log out page code
<?php require_once("includes/functions.php"); ?>
<?php
		// Four steps to closing a session
		// (i.e. logging out)
 
		// 1. Find the session
		session_start();
		
		// 2. Unset all the session variables
		$_SESSION = array();
		
		// 3. Destroy the session cookie
		if(isset($_COOKIE[session_name()])) {
			setcookie(session_name(), '', time()-42000, '/');
		}
		
		// 4. Destroy the session
		session_destroy();
		
?>

Open in new window

0
MrFahad
Asked:
MrFahad
1 Solution
 
masheikCommented:
hi
 this link will help you,
http://wildphp.com/
 
0
 
agamalCommented:
i think you need to change the logout button to look like the code attached .....

and keep the logout.php code as it is

<script type="text/javascript">
function logconfirm() {
var answer = confirm("Text or question you want to use");
if (answer== true)
 {
   window.location="logout.php";
 } }
</script>
<input type="button" onClick="logconfirm()" name="logout" value="logout">

Open in new window

0
 
Ray PaseurCommented:
@MrFahad: by the time you get to this script, it's too late!  A better place might be on the link to the logout script.  You can use the built-in window.confirm like this:

HTH, ~Ray
<a href="/logout.php" onClick="return confirm('Are you sure you want to Log Out');">Logout</a>

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
MrFahadAuthor Commented:
Thanks Ray, Great gay always give simple and easy answer yet very handy :D
0
 
Ray PaseurCommented:
Thanks for your kind words and for the points!  Enjoy your project, ~Ray
0
 
MrFahadAuthor Commented:
your welcome ray, by the way please take a look at my problem here:

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_24166113.html

:)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now