Documentation

Session
in package

The Session class allows your application to write data to a persistent space that automatically expires after a given time. This class allows you to quickly and comfortably select the persistence mechanism you want and continue working.

This class is a singleton. I've been working on reducing the amount of single instance objects inside of spitfire, but this class is somewhat special. It represents a single and global resource inside of PHP and therefore will only make the system unstable by allowing several instances.

Table of Contents

$handler  : SessionHandler
The session handler is in charge of storing the data to disk once the system is done reading it.
destroy()  : bool
Destroys the session. This code will automatically unset the session cookie, and delete the file (or whichever mechanism is used).
get()  : mixed
getHandler()  : mixed
getInstance()  : Session
This class requires to be managed in "singleton" mode, since there can only be one session handler for the system.
getUser()  : mixed
isSafe()  : mixed
lock()  : mixed
sessionId()  : bool
Returns the session ID being used.
set()  : mixed
setHandler()  : mixed
start()  : mixed
__construct()  : mixed
The Session allows the application to maintain a persistence across HTTP requests by providing the user with a cookie and maintaining the data on the server. Therefore, you can consider all the data you read from the session to be safe because it stems from the server.

Properties

$handler

The session handler is in charge of storing the data to disk once the system is done reading it.

private SessionHandler $handler

Methods

destroy()

Destroys the session. This code will automatically unset the session cookie, and delete the file (or whichever mechanism is used).

public destroy() : bool
Return values
bool

get()

public get(mixed $key[, mixed $app = null ]) : mixed
Parameters
$key : mixed
$app : mixed = null
Return values
mixed

getHandler()

public getHandler() : mixed
Return values
mixed

getInstance()

This class requires to be managed in "singleton" mode, since there can only be one session handler for the system.

public static getInstance() : Session
Tags
staticvar

Session $instance

Return values
Session

getUser()

public getUser([App $app = null ]) : mixed
Parameters
$app : App = null
Return values
mixed

isSafe()

public isSafe([App $app = null ]) : mixed
Parameters
$app : App = null
Return values
mixed

lock()

public lock(mixed $userdata[, App $app = null ]) : mixed
Parameters
$userdata : mixed
$app : App = null
Return values
mixed

sessionId()

Returns the session ID being used.

public static sessionId([bool $allowRegen = true ]) : bool

Since March 2017 the Spitfire session will validate that the session identifier returned is valid. A valid session ID is up to 128 characters long and contains only alphanumeric characters, dashes and commas.

Parameters
$allowRegen : bool = true

Allows the function to provide a new SID in case of the session ID not being valid.

Tags
todo

Move to instance

throws
Exception
Return values
bool

set()

public set(mixed $key, mixed $value[, mixed $app = null ]) : mixed
Parameters
$key : mixed
$value : mixed
$app : mixed = null
Return values
mixed

setHandler()

public setHandler(mixed $handler) : mixed
Parameters
$handler : mixed
Return values
mixed

start()

public start() : mixed
Return values
mixed

__construct()

The Session allows the application to maintain a persistence across HTTP requests by providing the user with a cookie and maintaining the data on the server. Therefore, you can consider all the data you read from the session to be safe because it stems from the server.

protected __construct([SessionHandler $handler = null ]) : mixed

You need to question the fact that the data actually belongs to the same user, since this may not be guaranteed all the time.

Parameters
$handler : SessionHandler = null
Return values
mixed

Search results