
Untitled
By: a guest on
Jun 30th, 2012 | syntax:
None | size: 0.65 KB | hits: 13 | expires: Never
Clicking link should expire the session
<img src="http://site.come/logout"/>
<input type="submit" name="logout" value="Logout"/>
<?php
if(isset($_POST['logout'])) {
session_destroy();
}
?>
<!--in the index.php page-->
<a href="logout.php">Logout</a>
<!--in the logout.php page-->
<?php
session_start(); //to ensure you are using same session
session_destroy(); //destroy the session
header("location:http://localhost/moon/index.php");
//to redirect back to "index.php" after logging out
exit();
?>
<?php
if(isset($_GET['expire'])){
session_start();
session_destroy();
}
?>
<a href="session_expr.php?expire">Destroy session</a>