interface JSessionHandlerInterface

Interface for managing HTTP sessions

Methods

boolean
start()

Starts the session.

boolean
isStarted()

Checks if the session is started.

string
getId()

Returns the session ID

void
setId( string $id)

Sets the session ID

mixed
getName()

Returns the session name

void
setName( string $name)

Sets the session name

boolean
regenerate( boolean $destroy = false, integer $lifetime = null)

Regenerates ID that represents this storage.

void
save()

Force the session to be saved and closed.

void
clear()

Clear all session data in memory.

Details

boolean start()

Starts the session.

Return Value

boolean True if started.

Exceptions

RuntimeException If something goes wrong starting the session.

boolean isStarted()

Checks if the session is started.

Return Value

boolean True if started, false otherwise.

string getId()

Returns the session ID

Return Value

string The session ID

void setId( string $id)

Sets the session ID

Parameters

string $id The session ID

Return Value

void

mixed getName()

Returns the session name

Return Value

mixed The session name.

void setName( string $name)

Sets the session name

Parameters

string $name The name of the session

Return Value

void

boolean regenerate( boolean $destroy = false, integer $lifetime = null)

Regenerates ID that represents this storage.

Note regenerate+destroy should not clear the session data in memory only delete the session data from persistent storage.

Parameters

boolean $destroy Destroy session when regenerating?
integer $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.

Return Value

boolean True if session regenerated, false if error

void save()

Force the session to be saved and closed.

This method must invoke sessionwriteclose() unless this interface is used for a storage object design for unit or functional testing where a real PHP session would interfere with testing, in which case it should actually persist the session data if required.

Return Value

void

Exceptions

RuntimeException If the session is saved without being started, or if the session is already closed.

See also

session_write_close()

void clear()

Clear all session data in memory.

Return Value

void