Skip to content
Snippets Groups Projects
Commit cddb7d91 authored by Andjelko Horvat's avatar Andjelko Horvat
Browse files

Add SimpleSAML_SessionHandler::getSessionCookieName() (patch 1 from issue #571).

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3275 44740490-163a-0410-bde0-09ae8108e29a
parent acb4051c
No related branches found
No related tags found
No related merge requests found
...@@ -63,6 +63,14 @@ abstract class SimpleSAML_SessionHandler { ...@@ -63,6 +63,14 @@ abstract class SimpleSAML_SessionHandler {
abstract public function getCookieSessionId(); abstract public function getCookieSessionId();
/**
* Retrieve the session cookie name.
*
* @return string The session cookie name.
*/
abstract public function getSessionCookieName();
/** /**
* Save the session. * Save the session.
* *
......
...@@ -76,6 +76,17 @@ extends SimpleSAML_SessionHandler { ...@@ -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 /* This static function creates a session id. A session id consists
* of 32 random hexadecimal characters. * of 32 random hexadecimal characters.
* *
......
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
*/ */
class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler { 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 /* Initialize the PHP session handling. This constructor is protected
* because it should only be called from * because it should only be called from
* SimpleSAML_SessionHandler::createSessionHandler(...). * SimpleSAML_SessionHandler::createSessionHandler(...).
...@@ -42,8 +46,12 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler { ...@@ -42,8 +46,12 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler {
session_set_cookie_params($params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']); session_set_cookie_params($params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']);
} }
$cookiename = $config->getString('session.phpsession.cookiename', NULL); $this->cookie_name = $config->getString('session.phpsession.cookiename', NULL);
if (!empty($cookiename)) session_name($cookiename); if (!empty($this->cookie_name)) {
session_name($this->cookie_name);
} else {
$this->cookie_name = session_name();
}
$savepath = $config->getString('session.phpsession.savepath', NULL); $savepath = $config->getString('session.phpsession.savepath', NULL);
if(!empty($savepath)) { if(!empty($savepath)) {
...@@ -109,6 +117,17 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler { ...@@ -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. * Save the current session to the PHP session array.
* *
...@@ -169,8 +188,7 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler { ...@@ -169,8 +188,7 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler {
*/ */
public function hasSessionCookie() { public function hasSessionCookie() {
$cookieName = session_name(); return array_key_exists($this->cookie_name, $_COOKIE);
return array_key_exists($cookieName, $_COOKIE);
} }
......
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