‪TYPO3CMS  10.4
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)
 
bool open ($savePath, $sessionName)
 
bool close ()
 
string read ($id)
 
bool write ($id, $sessionData)
 
bool destroy ($id)
 
bool gc ($maxLifeTime)
 
 __destruct ()
 
string getSessionId ()
 

Private Member Functions

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

Private Attributes

string $sessionPath = 'session/'
 
int $expirationTimeInMinutes = 60
 

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 28 of file FileSessionHandler.php.

Constructor & Destructor Documentation

◆ __construct()

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

◆ __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 220 of file FileSessionHandler.php.

Member Function Documentation

◆ close()

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

Close function. See @session_set_save_handler

Returns
‪bool

Definition at line 102 of file FileSessionHandler.php.

◆ destroy()

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

Destroys one session. See @session_set_save_handler

Parameters
string$id‪The session id
Returns
‪bool

Definition at line 182 of file FileSessionHandler.php.

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

◆ ensureSessionSavePathExists()

TYPO3\CMS\Install\Service\Session\FileSessionHandler::ensureSessionSavePathExists (   $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 264 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()

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

Garbage collect session info. See @session_set_save_handler

Parameters
int$maxLifeTime‪The setting of session.gc_maxlifetime
Returns
‪bool

Definition at line 194 of file FileSessionHandler.php.

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

◆ getSessionFile()

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

◆ getSessionHash()

string TYPO3\CMS\Install\Service\Session\FileSessionHandler::getSessionHash (   $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 243 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 TYPO3\CMS\Install\Service\Session\FileSessionHandler::getSessionId ( )

Returns the session ID of the running session.

Returns
‪string the session ID

Definition at line 230 of file FileSessionHandler.php.

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

◆ getSessionSavePath()

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

◆ open()

bool TYPO3\CMS\Install\Service\Session\FileSessionHandler::open (   $savePath,
  $sessionName 
)

Open function. See @session_set_save_handler

Parameters
string$savePath
string$sessionName
Returns
‪bool

Definition at line 92 of file FileSessionHandler.php.

◆ read()

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

Read session data. See @session_set_save_handler

Parameters
string$id‪The session id
Returns
‪string

Definition at line 113 of file FileSessionHandler.php.

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

◆ write()

bool TYPO3\CMS\Install\Service\Session\FileSessionHandler::write (   $id,
  $sessionData 
)

Write session data. See @session_set_save_handler

Parameters
string$id‪The session id
string$sessionData‪The data to be stored
Exceptions
Exception
Returns
‪bool

Definition at line 145 of file FileSessionHandler.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\fixPermissions(), and TYPO3\CMS\Install\Service\Session\FileSessionHandler\getSessionFile().

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

Member Data Documentation

◆ $expirationTimeInMinutes

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

time (minutes) to expire an unused session

Definition at line 44 of file FileSessionHandler.php.

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

◆ $sessionPath

string TYPO3\CMS\Install\Service\Session\FileSessionHandler::$sessionPath = 'session/'
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().