logout.php 667 B

1234567891011121314151617181920212223242526272829
  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. */
  17. function action(){
  18. setcookie("user_id", null, time() - 3600);
  19. setcookie("user_token", null, time() - 3600);
  20. session_regenerate_id();
  21. $_SESSION['session'] = false;
  22. $_SESSION['user_id'] = "";
  23. header("Location: /");
  24. die();
  25. return 0;
  26. }
  27. ?>