- if ($signout_page) {
- header("Status: 303 See Other");
- header("Location: $signout_page");
- exit; /* we send no content if we're redirecting. */
- }
+/* If a user hits reload on the last page, $base_uri isn't set
+ * because it was deleted with the session. */
+if (!isset($base_uri)) {
+ if (!function_exists('sqm_baseuri')){
+ require_once('../functions/display_messages.php');
+ }
+ $base_uri = sqm_baseuri();
+}
+
+do_hook('logout');
+setcookie('username', '', 0, $base_uri);
+setcookie('key', '', 0, $base_uri);
+session_destroy();
+
+if ($signout_page) {
+ header('Status: 303 See Other');
+ header("Location: $signout_page");
+ exit; /* we send no content if we're redirecting. */
+}