\Symfony\Component\HttpFoundation\Session\StoragePhpBridgeSessionStorage

Allows session to be started by PHP and managed by Symfony.

Summary

Methods
Properties
Constants
__construct()
getSaveHandler()
start()
getId()
setId()
getName()
setName()
regenerate()
save()
clear()
registerBag()
getBag()
setMetadataBag()
getMetadataBag()
isStarted()
setOptions()
setSaveHandler()
No public properties found
No constants found
loadSession()
$bags
$started
$closed
$saveHandler
$metadataBag
N/A
No private methods found
$emulateSameSite
N/A

Properties

$bags

$bags : \Symfony\Component\HttpFoundation\Session\SessionBagInterface[]

Type

SessionBagInterface[]

$started

$started : bool

Type

bool

$closed

$closed : bool

Type

bool

$saveHandler

$saveHandler : \Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy|\SessionHandlerInterface

Type

SessionHandlerInterface

$metadataBag

$metadataBag : \Symfony\Component\HttpFoundation\Session\Storage\MetadataBag

Type

MetadataBag

$emulateSameSite

$emulateSameSite : string|null

Type

string|null

Methods

__construct()

__construct(\Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy|\SessionHandlerInterface|null  $handler = null, \Symfony\Component\HttpFoundation\Session\Storage\MetadataBag  $metaBag = null) : mixed

Depending on how you want the storage driver to behave you probably want to override this constructor entirely.

Parameters

\Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy|\SessionHandlerInterface|null $handler
\Symfony\Component\HttpFoundation\Session\Storage\MetadataBag $metaBag

Returns

mixed —

getSaveHandler()

getSaveHandler() : \Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy|\SessionHandlerInterface

Gets the save handler instance.

Returns

\Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy|\SessionHandlerInterface —

start()

start() : bool

Starts the session.

Returns

bool —

getId()

getId() : string

Returns the session ID.

Returns

string —

setId()

setId(string  $id) : mixed

Sets the session ID.

Parameters

string $id

Returns

mixed —

getName()

getName() : string

Returns the session name.

Returns

string —

setName()

setName(string  $name) : mixed

Sets the session name.

Parameters

string $name

Returns

mixed —

regenerate()

regenerate(bool  $destroy = false, int  $lifetime = null) : bool

Regenerates id that represents this storage.

Parameters

bool $destroy

Destroy session when regenerating?

int $lifetime

Sets the cookie lifetime for the session cookie. A null value will leave the system settings unchanged, 0 sets the cookie to expire with browser session. Time is in seconds, and is not a Unix timestamp.

Returns

bool —

save()

save() : mixed

Force the session to be saved and closed.

Returns

mixed —

clear()

clear() : mixed

Clear all session data in memory.

Returns

mixed —

registerBag()

registerBag(\Symfony\Component\HttpFoundation\Session\SessionBagInterface  $bag) : mixed

Registers a SessionBagInterface for use.

Parameters

\Symfony\Component\HttpFoundation\Session\SessionBagInterface $bag

Returns

mixed —

getBag()

getBag(string  $name) : \Symfony\Component\HttpFoundation\Session\SessionBagInterface

Gets a SessionBagInterface by name.

Parameters

string $name

Returns

\Symfony\Component\HttpFoundation\Session\SessionBagInterface —

setMetadataBag()

setMetadataBag(\Symfony\Component\HttpFoundation\Session\Storage\MetadataBag  $metaBag = null) : mixed

Parameters

\Symfony\Component\HttpFoundation\Session\Storage\MetadataBag $metaBag

Returns

mixed —

getMetadataBag()

getMetadataBag() : \Symfony\Component\HttpFoundation\Session\Storage\MetadataBag

Gets the MetadataBag.

Returns

\Symfony\Component\HttpFoundation\Session\Storage\MetadataBag —

isStarted()

isStarted() : bool

Checks if the session is started.

Returns

bool —

setOptions()

setOptions(array  $options) : mixed

Sets session.* ini variables.

For convenience we omit 'session.' from the beginning of the keys. Explicitly ignores other ini keys.

Parameters

array $options

Session ini directives [key => value]

Returns

mixed —

setSaveHandler()

setSaveHandler(\Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy|\SessionHandlerInterface|null  $saveHandler = null) : mixed

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.

Parameters

\Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy|\SessionHandlerInterface|null $saveHandler

Throws

\InvalidArgumentException

Returns

mixed —

loadSession()

loadSession(array  $session = null) : mixed

Load the session with attributes.

After starting the session, PHP retrieves the session from whatever handlers are set to (either PHP's internal, or a custom save handler set with session_set_save_handler()). PHP takes the return value from the read() handler, unserializes it and populates $_SESSION with the result automatically.

Parameters

array $session

Returns

mixed —