Guest User

Untitled

a guest
Feb 16th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. session_unset(); //Unset any existing sessions
  2. session_start(); //Start a new session
  3. echo 'success';
  4. //Set user details as the sessions parameters for later use
  5. $_SESSION["user"] = $username;
  6. $_SESSION["userid"] = $row['id'];
  7. $_SESSION["firstname"] = $row['firstname'];
  8. $_SESSION["lastname"] = $row['lastname'];
  9. $_SESSION["perms"] = $row['permissions'];
  10. $_SESSION['start'] = time(); // Taking now logged in time.
  11. $_SESSION['api_key'] = $row['api_key'];
  12.  
  13. // Ending a session in 30 minutes from the starting time.
  14. $_SESSION['expire'] = $_SESSION['start'] + (30 * 60);
  15. //Redirect user to homepage after login
  16.  
  17. echo "<script>window.location.assign('index.php');</script>";
  18.  
  19. session_start();
  20. if (empty($_SESSION)) {
  21. header("Location: ../login.php");
  22. die("Please log in first");
  23. } else {
  24. $firstname = $_SESSION['firstname'];
  25. $lastname = $_SESSION['lastname'];
  26. $user_id = $_SESSION['userid'];
  27. }
Add Comment
Please, Sign In to add comment