Skip to content
Snippets Groups Projects
Commit a0407d17 authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Avoid session cookies being set twice, hopefully for good.

parent 72d787c2
No related branches found
No related tags found
No related merge requests found
...@@ -62,9 +62,9 @@ abstract class SimpleSAML_SessionHandler ...@@ -62,9 +62,9 @@ abstract class SimpleSAML_SessionHandler
/** /**
* Retrieve the session id of saved in the session cookie. * Retrieve the session ID saved in the session cookie, if there's one.
* *
* @return string The session id saved in the cookie. * @return string|null The session id saved in the cookie or null if no session cookie was set.
*/ */
abstract public function getCookieSessionId(); abstract public function getCookieSessionId();
......
...@@ -60,9 +60,9 @@ abstract class SimpleSAML_SessionHandlerCookie extends SimpleSAML_SessionHandler ...@@ -60,9 +60,9 @@ abstract class SimpleSAML_SessionHandlerCookie extends SimpleSAML_SessionHandler
/** /**
* Retrieve the session id of saved in the session cookie. * Retrieve the session ID saved in the session cookie, if there's one.
* *
* @return string The session id saved in the cookie. * @return string|null The session id saved in the cookie or null if no session cookie was set.
*/ */
public function getCookieSessionId() public function getCookieSessionId()
{ {
...@@ -74,8 +74,8 @@ abstract class SimpleSAML_SessionHandlerCookie extends SimpleSAML_SessionHandler ...@@ -74,8 +74,8 @@ abstract class SimpleSAML_SessionHandlerCookie extends SimpleSAML_SessionHandler
// check if we have a valid session id // check if we have a valid session id
if (!self::isValidSessionID($this->session_id)) { if (!self::isValidSessionID($this->session_id)) {
// we don't have a valid session. Create a new session id // invalid, disregard this session
return self::newSessionId(); return null;
} }
} }
......
...@@ -99,9 +99,9 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler ...@@ -99,9 +99,9 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler
/** /**
* Retrieve the session id of saved in the session cookie. * Retrieve the session ID saved in the session cookie, if there's one.
* *
* @return string The session id saved in the cookie. * @return string|null The session id saved in the cookie or null if no session cookie was set.
* *
* @throws SimpleSAML_Error_Exception If the cookie is marked as secure but we are not using HTTPS. * @throws SimpleSAML_Error_Exception If the cookie is marked as secure but we are not using HTTPS.
*/ */
...@@ -109,7 +109,7 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler ...@@ -109,7 +109,7 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler
{ {
if (session_id() === '') { if (session_id() === '') {
if (!self::hasSessionCookie()) { if (!self::hasSessionCookie()) {
return self::newSessionId(); return null;
} }
$session_cookie_params = session_get_cookie_params(); $session_cookie_params = session_get_cookie_params();
......
...@@ -43,6 +43,10 @@ class SimpleSAML_SessionHandlerStore extends SimpleSAML_SessionHandlerCookie ...@@ -43,6 +43,10 @@ class SimpleSAML_SessionHandlerStore extends SimpleSAML_SessionHandlerCookie
if ($sessionId === null) { if ($sessionId === null) {
$sessionId = $this->getCookieSessionId(); $sessionId = $this->getCookieSessionId();
if ($sessionId === null) {
// no session cookie, nothing to load
return null;
}
} }
$session = $this->store->get('session', $sessionId); $session = $this->store->get('session', $sessionId);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment