logout.php 653 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * File for the logout action.
  4. *
  5. * Implements an action function to be called from the {@see Controller}.
  6. *
  7. * @author Iñigo Valentin <i@inigovalentin.com>
  8. * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
  9. * @package SWDB
  10. */
  11. /**
  12. * Logs the user out and redirects to the login page.
  13. *
  14. * Invalidates cookies and session variables.
  15. *
  16. * @category Action
  17. */
  18. function action(){
  19. setcookie("user_id", null, time() - 3600);
  20. setcookie("user_token", null, time() - 3600);
  21. session_regenerate_id();
  22. $_SESSION['session'] = false;
  23. $_SESSION['user_id'] = "";
  24. header("Location: /");
  25. }