Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. $_SESSION["username"] = "$username";
  2. $_SESSION["user_id"] = "$user_id";
  3. $_SESSION["act_type"] = "$act_type";
  4.  
  5. <?php
  6.  
  7. session_start();
  8.  
  9. $user = 'jane';
  10. $pass = '654321';
  11.  
  12. if ( $user == $_POST[user] AND $pass == $_POST[pass] ) {
  13.  
  14. $_SESSION[user] = $user;
  15. header("location: secure.php");
  16. }
  17. else {
  18. echo "Bad Login";
  19. }
  20.  
  21. ?>
  22.  
  23. <form name="form1" method="post" action="index.php">
  24.  
  25. Username: <input name="user" type="text">
  26. <br />
  27. Password: <input name="pass" type="password">
  28. <br /><br />
  29. <input type="submit" name="Submit" value="Login">
  30. </form>
  31.  
  32. <?php
  33.  
  34. session_start();
  35.  
  36. if ( !isset($_SESSION[user]) ) {
  37.  
  38. header("location: index.php");
  39. }
  40.  
  41. ?>
  42. Secure Page
  43.  
  44. <?php
  45.  
  46. session_start();
  47.  
  48. $user = 'joe';
  49. $pass = '123456';
  50.  
  51. if ( $user == $_POST[user] AND $pass == $_POST[pass] ) {
  52.  
  53. $_SESSION[user] = $user;
  54. header("location: secure.php");
  55. }
  56. else {
  57. echo "Bad Login";
  58. }
  59.  
  60. ?>
  61.  
  62. <form name="form1" method="post" action="index.php">
  63.  
  64. Username: <input name="user" type="text">
  65. <br />
  66. Password: <input name="pass" type="password">
  67. <br /><br />
  68. <input type="submit" name="Submit" value="Login">
  69. </form>
  70.  
  71. <?php
  72.  
  73. session_start();
  74.  
  75. if ( !isset($_SESSION[user]) ) {
  76.  
  77. header("location: index.php");
  78. }
  79.  
  80. ?>
  81. Secure Page
  82.  
  83. $_SESSION["s1_username"] = $username;
  84. $_SESSION["s1_user_id"] = $user_id;
  85. $_SESSION["s1_act_type"] = $act_type;
  86.  
  87. $_SESSION["s2_username"] = $username;
  88. $_SESSION["s2_user_id"] = $user_id;
  89. $_SESSION["s2_act_type"] = $act_type;
  90.  
  91. foreach($_SESSION as $key => $value)
  92. {
  93. if (strpos($key, 's1_') === 0)
  94. {
  95. unset($_SESSION[$key]);
  96. }
  97. }
  98.  
  99. foreach($_SESSION as $key => $value)
  100. {
  101. if (strpos($key, 's2_') === 0)
  102. {
  103. unset($_SESSION[$key]);
  104. }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement