function NativeSessionStorage::setSaveHandler
Registers session save handler as a PHP session handler.
To use internal PHP session save handlers, override this method using ini_set with session.save_handler and session.save_path e.g.
ini_set('session.save_handler', 'files'); ini_set('session.save_path', '/tmp');
or pass in a \SessionHandler instance which configures session.save_handler in the constructor, for a template see NativeFileSessionHandler.
Throws
\InvalidArgumentException
See also
https://php.net/session-set-save-handler
https://php.net/sessionhandlerinterface
https://php.net/sessionhandler
2 calls to NativeSessionStorage::setSaveHandler()
- NativeSessionStorage::__construct in vendor/
symfony/ http-foundation/ Session/ Storage/ NativeSessionStorage.php - Depending on how you want the storage driver to behave you probably want to override this constructor entirely.
- PhpBridgeSessionStorage::__construct in vendor/
symfony/ http-foundation/ Session/ Storage/ PhpBridgeSessionStorage.php - Depending on how you want the storage driver to behave you probably want to override this constructor entirely.
File
-
vendor/
symfony/ http-foundation/ Session/ Storage/ NativeSessionStorage.php, line 364
Class
- NativeSessionStorage
- This provides a base class for session attribute storage.
Namespace
Symfony\Component\HttpFoundation\Session\StorageCode
public function setSaveHandler(AbstractProxy|\SessionHandlerInterface|null $saveHandler) : void {
// Wrap $saveHandler in proxy and prevent double wrapping of proxy
if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) {
$saveHandler = new SessionHandlerProxy($saveHandler);
}
elseif (!$saveHandler instanceof AbstractProxy) {
$saveHandler = new SessionHandlerProxy(new StrictSessionHandler(new \SessionHandler()));
}
$this->saveHandler = $saveHandler;
if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) {
return;
}
if ($this->saveHandler instanceof SessionHandlerProxy) {
session_set_save_handler($this->saveHandler, false);
}
}