Silverstripe Version: 4.11.15 to higher
Question: Upgrading from silvestripe framework 4.11.15 to higher is making to loose session state
Hi,
Currently one of the site I am managing is running on Silverstripe framework 4.11.15. We have SSO configured via OpenID. All is working fine with this version.
Once we upgrade Silverstripe framework from 4.11.15 to anything higher the session state is not working ie after SSO session is loosing the state.
We have custom implementation of Session class. A wrapper to already existing Control\Session.php class.
Once we upgrade the framework, the user is redirected in a loop. Upon troubleshooting what we found was the sate of the session is not getting saved. When we downgrade everything works fine with no issues.
I have been through the Session documentation and have added cookie_samesite=‘Strict’.
Posting a question here in the forum if anyone else had similar experience and if I am missing something after the upgrade that I need to do for sessions to work.
Really appreciate any help here please.
Common Session class in one of our common modules used across three sites.
class Session
{
private static $inst = null;
private $session = null;
public function __construct()
{
if (Controller::curr()) {
$request = Controller::curr()->getRequest();
$this->session = $request->getSession();
}
}
public function startSession()
{
$request = Injector::inst()->get(HTTPRequest::class);
return $this->session ? $this->session->start($request) : false;
}
public function getValue($name)
{
return $this->session ? $this->session->get($name) : null;
}
public function setValue($name, $value)
{
return $this->session ? $this->session->set($name, $value) : null;
}
public function getAllValues()
{
return $this->session ? $this->session->getAll() : [];
}
public function clearValue($name)
{
return $this->session ? $this->session->clear($name) : false;
}
public function clearAllValues()
{
return $this->session ? $this->session->clearAll() : false;
}
public function saveSession()
{
$request = Injector::inst()->get(HTTPRequest::class);
return $this->session ? $this->session->save($request) : false;
}
public function destroySession()
{
return $this->session ? $this->session->destroy(true) : false;
}
public static function init()
{
if (!isset(self::$inst)) {
self::$inst = new Session();
}
return self::$inst;
}
public static function start()
{
return self::init()->startSession();
}
public static function get($name)
{
return self::init()->getValue($name);
}
public static function set($name, $value)
{
return self::init()->setValue($name, $value);
}
public static function get_all()
{
return self::init()->getAllValues();
}
public static function clear($name)
{
return self::init()->clearValue($name);
}
public static function clear_all()
{
return self::init()->clearAllValues();
}
public static function save()
{
return self::init()->saveSession();
}
public static function destroy()
{
return self::init()->destroySession();
}
}