logout.php 849 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. require_once 'session.php';
  3. require_once 'database.php';
  4. // Not a valid session
  5. if (!Session::is_valid ())
  6. {
  7. header ('Location: ./');
  8. exit ();
  9. }
  10. // Delete "remember_me" cookie
  11. if (isset ($_COOKIE['remember_me']))
  12. {
  13. $db = new Database ();
  14. $db->connect ();
  15. $db->delete_remember_me (Session::get_userid ());
  16. unset ($_COOKIE['remember_me']);
  17. // Invalidate cookie
  18. setcookie (
  19. 'remember_me', // name
  20. NULL, // value
  21. -1, // expire
  22. '/', // path
  23. 'freepo.st', // domain
  24. false, // secure (clients send cookie only through HTTPS)
  25. true); // httponly (no javascript)
  26. }
  27. // Delete session
  28. Session::delete ();
  29. // Logged out, redirect to homepage
  30. header ('Location: ./');
  31. exit ();