Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 23rd, 2013  |  syntax: None  |  size: 0.70 KB  |  views: 79  |  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. session1.php file
  2.  
  3. <?php
  4.  
  5. session_start();  
  6. if(isset($_SESSION['views']))
  7.     $_SESSION['views'] = $_SESSION['views']+ 1;
  8. else
  9.     $_SESSION['views'] = 1;
  10.  
  11. echo "views = ". $_SESSION['views'];
  12.  
  13. ?>
  14.  
  15. <!doctype html>
  16.  
  17. <head>
  18.  
  19. </head>
  20.  
  21. <body>
  22.  
  23. <script type="text/javascript">
  24.  
  25. function logoutck() {
  26.     var r = confirm("Do you really want to log out?");
  27.     if (r) {
  28.        window.location.href = 'logout.php'
  29.     }
  30. }
  31.  
  32. </script>
  33.  
  34. <input id="button1" type='button' onclick='logoutck();' value='LOGOUT'/>
  35.  
  36. </body>
  37.  
  38. </html>
  39.  
  40. logout.php file
  41.  
  42. <?php
  43.  
  44. session_start();
  45.  
  46. if(isset($_SESSION['views']))
  47.     unset($_SESSION['views']);
  48.  
  49. header("Location: session1.php");
  50.  
  51. ?>