Jump to content

[SOLVED] Logout Validation


KaFF

Recommended Posts

You could do javascript...

 

<script language="JavaScript">
function confirmLogout()
{
var agree=confirm("Are you sure you want to log out?");
if (agree)
return true ;
else
return false ;
}
</script>

 

then for a link

 

<a href="logout.php" onClick="return confirmLogout()">logout</a>

I tried using the javascript code as i currently have a href logout link on my pages but when i used the code in my logout.php it returned a blank page and didnt give the option of saying are you sure you want to logout.

I am using session variables at the top of my pages and the logout page currently looks like this

 

<?php
session_start();
session_destroy();
header("location:login.php");
exit();
?>

 

If you could tell me where i am going wrong i would greatly appreciate it.

 

KaFF

You could do javascript...

 

<script language="JavaScript">
function confirmLogout()
{
var agree=confirm("Are you sure you want to log out?");
if (agree)
return true ;
else
return false ;
}
</script>

 

then for a link

 

<a href="logout.php" onClick="return confirmLogout()">logout</a>

 

I just tried using this script on my site, exactly as it was written, and with both buttons "Cancel" and "Agree" I was still logged out...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.