Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. function checkLogin() {
  2. global $errorMessage;
  3.  
  4. $username = $_POST['inputEmail'];
  5. $password = $_POST['inputPassword'];
  6. $remember = isset($_POST['remember-me']);
  7.  
  8. try {
  9. $account = Account::getAccount($username, $password);
  10. } catch (Exception $ex) {
  11. $errorMessage = "An internal error occured :(. We're sorry about this.<br>";
  12. }
  13.  
  14. if ($account) {
  15. $_SESSION['account'] = $account;
  16. if ($remember) {
  17. setcookie('account', serialize($account), time() + (86400 * 30), '/');
  18. }
  19. header('Location: admin.php');
  20. } else {
  21. $errorMessage .= "Incorrect username or password. Please try again.";
  22. }
  23. }
  24.  
  25. function logout() {
  26. $_SESSION['account'] = null;
  27. session_destroy();
  28. setcookie('account', null, -1, '/');
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement