SHARE
TWEET

Untitled

a guest Jul 23rd, 2013 238 Never
  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. ?>
RAW Paste Data
Top