Guest User

Untitled

a guest
Jun 13th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <?php
  2. if (isset($_COOKIE['PHPSESSID'])) {
  3. session_start();
  4. }
  5.  
  6. if (isset($_POST['user'])) {
  7. if ($_POST['user'] != '') {
  8. $user = $_POST['user'];
  9. }
  10. if(isset($_POST['password'])) {
  11. if ($_POST['user'] != '') {
  12. $password = $_POST['password'];
  13. }
  14. }
  15. if (isset($user) && isset($password)) {
  16. session_regenerate_id(true);
  17. $_SESSION['user'] = $user;
  18. $_SESSION['password'] = $password;
  19. }
  20. }
  21.  
  22.  
  23. ?>
  24. <html>
  25. <head>
  26. <title>PHP Sessions</title>
  27. <style type="text/css">
  28. body {
  29. text-align: center;
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. <?php
  35. //CHECK FOR SESSION
  36. if(!isset($_SESSION['user']))
  37. {
  38.  
  39.  
  40. ?>
  41.  
  42. <h1>Login Page</h1>
  43. <h2>Today is<?php echo date("l \\t\h\e jS"); ?></h2>
  44. <h3>Session ID is: <?php echo session_id(); ?></h3>
  45. <form method="POST" action="php">
  46. <label>Username:</label> <input type="text" id="user" name="user" /><br /><br />
  47. <label>Password:</label> <input type="password" id="password" name="password" /><br /><br />
  48. <input type="submit" name="login" id="login" value="Login" />
  49. </form>
  50. <?php
  51. }
  52. else
  53. {
  54. echo "<h1>You are now logged in!</h1>";
  55. echo "<h3>The new Session ID is: ";
  56. echo session_id();
  57. echo "</h3>";
  58. var_dump($_COOKIE);
  59.  
  60. }
  61.  
  62. ?>
  63. </body>
  64. </html>
Add Comment
Please, Sign In to add comment