Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 0.65 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Clicking link should expire the session
  2. <img src="http://site.come/logout"/>
  3.        
  4. <input type="submit" name="logout" value="Logout"/>
  5.  
  6. <?php
  7.     if(isset($_POST['logout'])) {
  8.         session_destroy();
  9.     }
  10. ?>
  11.        
  12. <!--in the index.php page-->
  13.  
  14. <a href="logout.php">Logout</a>
  15.  
  16.  
  17. <!--in the logout.php page-->
  18.  
  19. <?php
  20. session_start(); //to ensure you are using same session
  21. session_destroy(); //destroy the session
  22. header("location:http://localhost/moon/index.php");
  23. //to redirect back to "index.php" after logging out
  24. exit();
  25. ?>
  26.        
  27. <?php
  28.  
  29. if(isset($_GET['expire'])){
  30. session_start();
  31. session_destroy();
  32. }
  33.  
  34. ?>
  35. <a href="session_expr.php?expire">Destroy session</a>