logout.php 770 B

123456789101112131415161718192021222324252627282930313233
  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. * @param resource $db Database connection.
  15. * @return int 0.
  16. * @category Action
  17. * @global int The user id.
  18. */
  19. function action($db = null){
  20. global $UID;
  21. $UID = null;
  22. setcookie("uid", null, time() - 3600);
  23. session_regenerate_id();
  24. $_SESSION['session'] = false;
  25. $_SESSION['name'] = "";
  26. $_SESSION['uid'] = "";
  27. header("Location: /");
  28. die();
  29. return 0;
  30. }
  31. ?>