Advertisement
Guest User

Untitled

a guest
May 15th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. // This method checks if the user is logged in, and also checks if the user is logged in as administrator or client, if neither, it will return errors which will send the user back to index.php or adminindex.php
  2. function checkSession() {
  3. if($_SESSION["id"] == session_id() && $_SESSION["active"] == 1) {
  4. if($_SESSION["usertype"] == 'client' || $_SESSION["usertype"] == 'administator') {
  5. return true;
  6. } else {
  7. $errors[] = "Session invalid. Please log in again ...";
  8. return $errors;
  9. }
  10. }
  11. }
  12.  
  13. // this checks if the user is logged in, if not, it will attempt to log the user in, if that fails, output errors which will send the user to the login page.
  14. function isloggedin($username='', $password='', $type='') {
  15. if($this->checkSession() == true) {
  16. // This user is already logged in
  17. return true;
  18. } elseif(strlen($username) && strlen($password) && strlen($type)) {
  19. // This user is not logged in already, but they provided login information, so let's attempt to log them in:
  20. $output = $this->authCheck($username, $password, $type);
  21. if(is_array($output)) {
  22. // We got errors, return them
  23. return $output;
  24. }
  25. if($output === true) {
  26. return true;
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement