logout.php 729 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * File for the login action.
  4. *
  5. * Implements an action function to be called from the {@see Controller}.
  6. *
  7. * @category Action
  8. */
  9. /**
  10. * Logs the user out and redirects to the login page.
  11. *
  12. * Invalidates cookies and session variables.
  13. *
  14. * @return int 0.
  15. * @category Action
  16. * @global User The logged-in user.
  17. */
  18. function action(){
  19. $USER = null;
  20. setcookie("user_id", null, time() - 3600);
  21. setcookie("user_token", null, time() - 3600);
  22. session_regenerate_id();
  23. $_SESSION['session'] = false;
  24. $_SESSION['user_id'] = "";
  25. header("Location: /");
  26. die();
  27. return 0;
  28. }
  29. ?>