‪TYPO3CMS  ‪main
TYPO3\CMS\Install\Service\Session\FileSessionHandler Class Reference
Inheritance diagram for TYPO3\CMS\Install\Service\Session\FileSessionHandler:

Public Member Functions

 __construct (string $sessionPath, int $expirationTimeInMinutes, private readonly HashService $hashService)
 
 open (string $path, string $name)
 
 close ()
 
 read (string $id)
 
 write (string $id, string $data)
 
 destroy (string $id)
 
 gc (int $maxLifeTime)
 
 __destruct ()
 
string false getSessionId ()
 

Private Member Functions

string getSessionSavePath ()
 
string getSessionFile (string $id)
 
string getSessionHash (string $sessionId='')
 
 ensureSessionSavePathExists (string $sessionSavePath)
 

Private Attributes

string $sessionPath
 
int $expirationTimeInMinutes
 

Detailed Description

PHP session handling with "secure" session files (hashed session id) see http://www.php.net/manual/en/function.session-set-save-handler.php

Definition at line 29 of file FileSessionHandler.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Install\Service\Session\FileSessionHandler::__construct ( string  $sessionPath,
int  $expirationTimeInMinutes,
private readonly HashService  $hashService 
)

◆ __destruct()

TYPO3\CMS\Install\Service\Session\FileSessionHandler::__destruct ( )

Writes the session data at the end, to overcome a PHP APC bug.

Writes the session data in a proper context that is not affected by the APC bug: http://pecl.php.net/bugs/bug.php?id=16721.

This behaviour was introduced in #17511, where self::write() made use of GeneralUtility which due to the APC bug throws a "Fatal error: Class 'GeneralUtility' not found" (and the session data is not saved). Calling session_write_close() at this point seems to be the most easy solution, according to PHP author.

Definition at line 205 of file FileSessionHandler.php.

Member Function Documentation

◆ close()

TYPO3\CMS\Install\Service\Session\FileSessionHandler::close ( )

Close function. See @session_set_save_handler

Definition at line 97 of file FileSessionHandler.php.

◆ destroy()

TYPO3\CMS\Install\Service\Session\FileSessionHandler::destroy ( string  $id)

Destroys one session. See @session_set_save_handler

Definition at line 166 of file FileSessionHandler.php.

References TYPO3\CMS\Install\Service\Session\FileSessionHandler\getSessionFile().

◆ ensureSessionSavePathExists()

TYPO3\CMS\Install\Service\Session\FileSessionHandler::ensureSessionSavePathExists ( string  $sessionSavePath)
private

Create directories for the session save path and throw an exception if that fails.

Parameters
string$sessionSavePath‪The absolute path to the session files
Exceptions

Definition at line 249 of file FileSessionHandler.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\mkdir_deep(), and TYPO3\CMS\Core\Utility\GeneralUtility\writeFile().

Referenced by TYPO3\CMS\Install\Service\Session\FileSessionHandler\getSessionSavePath().

◆ gc()

TYPO3\CMS\Install\Service\Session\FileSessionHandler::gc ( int  $maxLifeTime)

Garbage collect session info. See @session_set_save_handler

Parameters
int$maxLifeTime‪The setting of session.gc_maxlifetime

Definition at line 177 of file FileSessionHandler.php.

References TYPO3\CMS\Install\Service\Session\FileSessionHandler\getSessionSavePath().

◆ getSessionFile()

string TYPO3\CMS\Install\Service\Session\FileSessionHandler::getSessionFile ( string  $id)
private

◆ getSessionHash()

string TYPO3\CMS\Install\Service\Session\FileSessionHandler::getSessionHash ( string  $sessionId = '')
private

Returns a session hash, which can only be calculated by the server. Used to store our session files without exposing the session ID.

Parameters
string$sessionId‪An alternative session ID. Defaults to our current session ID
Exceptions

Definition at line 228 of file FileSessionHandler.php.

References $GLOBALS, and TYPO3\CMS\Install\Service\Session\FileSessionHandler\getSessionId().

Referenced by TYPO3\CMS\Install\Service\Session\FileSessionHandler\getSessionFile().

◆ getSessionId()

string false TYPO3\CMS\Install\Service\Session\FileSessionHandler::getSessionId ( )

Returns the session ID of the running session.

Returns
‪string|false the session ID

Definition at line 215 of file FileSessionHandler.php.

Referenced by TYPO3\CMS\Install\Service\Session\FileSessionHandler\getSessionHash().

◆ getSessionSavePath()

string TYPO3\CMS\Install\Service\Session\FileSessionHandler::getSessionSavePath ( )
private

◆ open()

TYPO3\CMS\Install\Service\Session\FileSessionHandler::open ( string  $path,
string  $name 
)

Open function. See @session_set_save_handler

Definition at line 89 of file FileSessionHandler.php.

◆ read()

TYPO3\CMS\Install\Service\Session\FileSessionHandler::read ( string  $id)

◆ write()

TYPO3\CMS\Install\Service\Session\FileSessionHandler::write ( string  $id,
string  $data 
)

Member Data Documentation

◆ $expirationTimeInMinutes

int TYPO3\CMS\Install\Service\Session\FileSessionHandler::$expirationTimeInMinutes
private

time (minutes) to expire an unused session

Definition at line 43 of file FileSessionHandler.php.

Referenced by TYPO3\CMS\Install\Service\Session\FileSessionHandler\__construct().

◆ $sessionPath

string TYPO3\CMS\Install\Service\Session\FileSessionHandler::$sessionPath
private

The path to our var/session/ folder (where we can write our sessions). Set in the constructor. Path where to store our session files in var/session/.

Definition at line 38 of file FileSessionHandler.php.

Referenced by TYPO3\CMS\Install\Service\Session\FileSessionHandler\__construct().