Drupal 8  8.0.2
SessionManager Class Reference
Inheritance diagram for SessionManager:

Public Member Functions

 __construct (RequestStack $request_stack, Connection $connection, MetadataBag $metadata_bag, SessionConfigurationInterface $session_configuration, $handler=NULL)
 
 start ()
 
 save ()
 
 regenerate ($destroy=FALSE, $lifetime=NULL)
 
 delete ($uid)
 
 destroy ()
 
 setWriteSafeHandler (WriteSafeSessionHandlerInterface $handler)
 

Protected Member Functions

 startNow ()
 
 isCli ()
 
 isSessionObsolete ()
 
 getSessionDataMask ()
 
 migrateStoredSession ($old_session_id)
 

Protected Attributes

 $requestStack
 
 $connection
 
 $sessionConfiguration
 
 $startedLazy
 
 $writeSafeHandler
 

Detailed Description

Manages user sessions.

This class implements the custom session management code inherited from Drupal 7 on top of the corresponding Symfony component. Regrettably the name NativeSessionStorage is not quite accurate. In fact the responsibility for storing and retrieving session data has been extracted from it in Symfony 2.1 but the class name was not changed.

Todo:
In fact the NativeSessionStorage class already implements all of the functionality required by a typical Symfony application. Normally it is not necessary to subclass it at all. In order to reach the point where Drupal can use the Symfony session management unmodified, the code implemented here needs to be extracted either into a dedicated session handler proxy (e.g. sid-hashing) or relocated to the authentication subsystem.

Constructor & Destructor Documentation

__construct ( RequestStack  $request_stack,
Connection  $connection,
MetadataBag  $metadata_bag,
SessionConfigurationInterface  $session_configuration,
  $handler = NULL 
)

Constructs a new session manager instance.

Parameters
\Symfony\Component\HttpFoundation\RequestStack$request_stackThe request stack.
\Drupal\Core\Database\Connection$connectionThe database connection.
\Drupal\Core\Session\MetadataBag$metadata_bagThe session metadata bag.
\Drupal\Core\Session\SessionConfigurationInterface$session_configurationThe session configuration interface.
\Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy | Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler | \SessionHandlerInterface | NULL$handlerThe object to register as a PHP session handler.
See Also
::setSaveHandler()

References Drupal\requestStack().

Here is the call graph for this function:

Member Function Documentation

delete (   $uid)

{Ends a specific user's session(s).

Parameters
int$uidUser ID.
}

Implements SessionManagerInterface.

References SessionManager\isCli().

Here is the call graph for this function:

destroy ( )

{Destroys the current session and removes session cookies.}

Implements SessionManagerInterface.

References Drupal\requestStack().

Referenced by SessionManager\save().

Here is the call graph for this function:

Here is the caller graph for this function:

getSessionDataMask ( )
protected

Returns a map specifying which session key is containing user data.

Returns
array An array where keys correspond to the session keys and the values are booleans specifying whether the corresponding session key contains any user data.

Referenced by SessionManager\isSessionObsolete().

Here is the caller graph for this function:

isCli ( )
protected

Returns whether the current PHP process runs on CLI.

Command line clients do not support cookies nor sessions.

Returns
bool

Referenced by SessionManager\delete(), SessionManager\regenerate(), SessionManager\save(), and SessionManager\startNow().

Here is the caller graph for this function:

isSessionObsolete ( )
protected

Determines whether the session contains user data.

Returns
bool TRUE when the session does not contain any values and therefore can be destroyed.

References SessionManager\getSessionDataMask().

Referenced by SessionManager\save().

Here is the call graph for this function:

Here is the caller graph for this function:

migrateStoredSession (   $old_session_id)
protected

Migrates the current session to a new session id.

Parameters
string$old_session_idThe old session ID. The new session ID is $this->getId().

References Crypt\hashBase64().

Referenced by SessionManager\regenerate().

Here is the call graph for this function:

Here is the caller graph for this function:

regenerate (   $destroy = FALSE,
  $lifetime = NULL 
)

{}

References SessionManager\isCli(), SessionManager\migrateStoredSession(), Crypt\randomBytesBase64(), and SessionManager\startNow().

Here is the call graph for this function:

save ( )

{}

References SessionManager\destroy(), SessionManager\isCli(), SessionManager\isSessionObsolete(), and SessionManager\startNow().

Here is the call graph for this function:

setWriteSafeHandler ( WriteSafeSessionHandlerInterface  $handler)

{}

Implements SessionManagerInterface.

start ( )

{}

References Crypt\randomBytesBase64(), Drupal\requestStack(), and SessionManager\startNow().

Here is the call graph for this function:

startNow ( )
protected

Forcibly start a PHP session.

Returns
bool TRUE if the session is started.

References SessionManager\isCli().

Referenced by SessionManager\regenerate(), SessionManager\save(), and SessionManager\start().

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: