Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- session_unset(); //Unset any existing sessions
- session_start(); //Start a new session
- echo 'success';
- //Set user details as the sessions parameters for later use
- $_SESSION["user"] = $username;
- $_SESSION["userid"] = $row['id'];
- $_SESSION["firstname"] = $row['firstname'];
- $_SESSION["lastname"] = $row['lastname'];
- $_SESSION["perms"] = $row['permissions'];
- $_SESSION['start'] = time(); // Taking now logged in time.
- $_SESSION['api_key'] = $row['api_key'];
- // Ending a session in 30 minutes from the starting time.
- $_SESSION['expire'] = $_SESSION['start'] + (30 * 60);
- //Redirect user to homepage after login
- echo "<script>window.location.assign('index.php');</script>";
- session_start();
- if (empty($_SESSION)) {
- header("Location: ../login.php");
- die("Please log in first");
- } else {
- $firstname = $_SESSION['firstname'];
- $lastname = $_SESSION['lastname'];
- $user_id = $_SESSION['userid'];
- }
Add Comment
Please, Sign In to add comment