Advertisement
Guest User

Untitled

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