Skip to content
Browse files

added test if a session is available for PHP 5.4

  • Loading branch information...
1 parent 0edd03f commit 3a7f50dfbd263fad0d591c4426ce4519e3f2996c @jonasjonas jonasjonas committed Apr 30, 2012
Showing with 15 additions and 6 deletions.
  1. +15 −6 www/framework/auth/auth_http_cookie.php
View
21 www/framework/auth/auth_http_cookie.php
@@ -150,16 +150,25 @@ protected function start_session() {
// }}}
// {{{ has_session()
protected function has_session() {
- return isset($_COOKIE[session_name()]) && $_COOKIE[session_name()] != "";
+ if (is_callable("session_status") && session_status() == PHP_SESSION_ACTIVE) {
+ // PHP 5.4
+ return true;
+ } else {
+ return isset($_COOKIE[session_name()]) && $_COOKIE[session_name()] != "";
+ }
}
// }}}
// {{{ destroy_session()
protected function destroy_session() {
- //$this->start_session();
-
- setcookie(session_name(), "", time() - 3600, $this->cookiepath);
- session_destroy();
- unset($_COOKIE[session_name()]);
+ if (!is_callable("session_status") || session_status() == PHP_SESSION_ACTIVE) {
+ $params = session_get_cookie_params();
+ setcookie(session_name(), '', time() - 42000,
+ $params["path"], $params["domain"],
+ $params["secure"], $params["httponly"]
+ );
+ session_destroy();
+ unset($_COOKIE[session_name()]);
+ }
}
// }}}

0 comments on commit 3a7f50d

Please sign in to comment.
Something went wrong with that request. Please try again.