diff --git a/src/Sifo/Session.php b/src/Sifo/Session.php index 4b4ff292..caf5b70b 100644 --- a/src/Sifo/Session.php +++ b/src/Sifo/Session.php @@ -25,7 +25,7 @@ class Session static private $instance; - private function __construct() + private function __construct($session_name) { if ( !headers_sent( ) ) { @@ -39,13 +39,15 @@ private function __construct() if ( headers_sent ( ) ) { trigger_error( "Session: The session was not started before the sending of the headers." ); - return false; + return; } - else - { - // Session init. - session_start(); + + if ($session_name instanceof SessionNameStrategy) { + $session_name->set(); } + + // Session init. + session_start(); } } @@ -56,10 +58,20 @@ private function __construct() * @return Session */ public static function getInstance() - { + { if ( !isset( self::$instance ) ) { - self::$instance = new self(); + $session_name_environment = FilterEnv::getInstance()->getString('SESSION_NAME'); + + switch ($session_name_environment) { + case 'environment_and_vertical': + $session_name_strategy = new SessionEnvironmentStrategy(); + break; + default: + $session_name_strategy = null; + } + + self::$instance = new self($session_name_strategy); } return self::$instance; } diff --git a/src/Sifo/Session/SessionEnvironmentStrategy.php b/src/Sifo/Session/SessionEnvironmentStrategy.php new file mode 100644 index 00000000..62f19c23 --- /dev/null +++ b/src/Sifo/Session/SessionEnvironmentStrategy.php @@ -0,0 +1,15 @@ +getInstanceInheritance(); + $vertical_instance = array_pop($instance_inheritance); + $instance_environment_initial = isset($_SERVER['APP_ENV'][0]) ? $_SERVER['APP_ENV'][0] : ''; + $instance_session_name = "SSID_{$instance_environment_initial}_{$vertical_instance}"; + session_name($instance_session_name); + } +} diff --git a/src/Sifo/Session/SessionNameStrategy.php b/src/Sifo/Session/SessionNameStrategy.php new file mode 100644 index 00000000..13c287bc --- /dev/null +++ b/src/Sifo/Session/SessionNameStrategy.php @@ -0,0 +1,8 @@ +