diff --git a/lib/SimpleSAML/SessionHandler.php b/lib/SimpleSAML/SessionHandler.php index 2d1a28c9075718dbb6abe37f72e966c2ba4553ec..1a44c559beeef88224cec5e31277cab6ef9d0082 100644 --- a/lib/SimpleSAML/SessionHandler.php +++ b/lib/SimpleSAML/SessionHandler.php @@ -63,6 +63,14 @@ abstract class SimpleSAML_SessionHandler { abstract public function getCookieSessionId(); + /** + * Retrieve the session cookie name. + * + * @return string The session cookie name. + */ + abstract public function getSessionCookieName(); + + /** * Save the session. * diff --git a/lib/SimpleSAML/SessionHandlerCookie.php b/lib/SimpleSAML/SessionHandlerCookie.php index 7c5ae37a79214a4f7ec995eb4f56986ea9bcd46a..1e01d86ba11cbefc35bbf11b0e451b1cc92f38b8 100644 --- a/lib/SimpleSAML/SessionHandlerCookie.php +++ b/lib/SimpleSAML/SessionHandlerCookie.php @@ -76,6 +76,17 @@ extends SimpleSAML_SessionHandler { } + /** + * Retrieve the session cookie name. + * + * @return string The session cookie name. + */ + public function getSessionCookieName() { + + return $this->cookie_name; + } + + /* This static function creates a session id. A session id consists * of 32 random hexadecimal characters. * diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php index 17480b68cb119e0ab2ccd4a27edc303cbb0b125c..1e73054895398dea243be720efc2989a36d2e67e 100644 --- a/lib/SimpleSAML/SessionHandlerPHP.php +++ b/lib/SimpleSAML/SessionHandlerPHP.php @@ -13,6 +13,10 @@ */ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler { + /* This variable contains the session cookie name. */ + protected $cookie_name; + + /* Initialize the PHP session handling. This constructor is protected * because it should only be called from * SimpleSAML_SessionHandler::createSessionHandler(...). @@ -42,8 +46,12 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler { session_set_cookie_params($params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']); } - $cookiename = $config->getString('session.phpsession.cookiename', NULL); - if (!empty($cookiename)) session_name($cookiename); + $this->cookie_name = $config->getString('session.phpsession.cookiename', NULL); + if (!empty($this->cookie_name)) { + session_name($this->cookie_name); + } else { + $this->cookie_name = session_name(); + } $savepath = $config->getString('session.phpsession.savepath', NULL); if(!empty($savepath)) { @@ -109,6 +117,17 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler { } + /** + * Retrieve the session cookie name. + * + * @return string The session cookie name. + */ + public function getSessionCookieName() { + + return $this->cookie_name; + } + + /** * Save the current session to the PHP session array. * @@ -169,8 +188,7 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler { */ public function hasSessionCookie() { - $cookieName = session_name(); - return array_key_exists($cookieName, $_COOKIE); + return array_key_exists($this->cookie_name, $_COOKIE); }