final class FileSessionStorage implements SessionStorageInterface (View source)

internal  Construct through SessionFactory so the public filesystem root is supplied
 

Persists sliding sessions in private atomically replaced files

A short global lock coordinates path mutations. Reads use atomic snapshots, while concurrent payload changes remain last-writer-wins.

Constants

private COOKIE_NAME

private GC_CURSOR_FILE

private MUTATION_LOCK_FILE

private TEMPORARY_FILE_PREFIX

private DEFAULT_GC_BATCH_SIZE

private MINIMUM_TEMPORARY_FILE_AGE_SECONDS

Methods

__construct(string $directory, string $publicRoot, int $lifetimeSeconds = 7200, string $cookieName = self::COOKIE_NAME, int $gcBatchSize = self::DEFAULT_GC_BATCH_SIZE, SessionCookie|null $cookie = null, SessionGarbageCollectionPolicy|null $garbageCollectionPolicy = null)

Defines private storage, retention, cookie identity and bounded garbage collection

void
start()

Loads an existing session or creates a new identity

void
bool

Reports whether the session has started during this request

bool
bool
has(string $key)

Checks whether a value exists, including an explicit null

bool
mixed
get(string $key, mixed $default = null)

Returns a stored value or the supplied fallback

mixed
void
set(string $key, mixed $value)

Stores a value through atomic session-file replacement

void
void
remove(string $key)

Removes a value and atomically persists the remaining payload

void
void
clear()

Clears the payload while retaining the current identity

void
void

Deletes the active record, expires its cookie and releases its identity

void
void
regenerate(bool $deleteOldSession = true)

Moves the payload to a new identity and optionally deletes the old record

void

Details

__construct

__construct(string $directory, string $publicRoot, int $lifetimeSeconds = 7200, string $cookieName = self::COOKIE_NAME, int $gcBatchSize = self::DEFAULT_GC_BATCH_SIZE, SessionCookie|null $cookie = null, SessionGarbageCollectionPolicy|null $garbageCollectionPolicy = null)

Defines private storage, retention, cookie identity and bounded garbage collection

Parameters

string $directory
string $publicRoot
int $lifetimeSeconds
string $cookieName
int $gcBatchSize
SessionCookie|null $cookie
SessionGarbageCollectionPolicy|null $garbageCollectionPolicy

start

void start()

Loads an existing session or creates a new identity

Return Value

void

started

bool started()

Reports whether the session has started during this request

Return Value

bool

has

bool has(string $key)

Checks whether a value exists, including an explicit null

Parameters

string $key

Return Value

bool

get

mixed get(string $key, mixed $default = null)

Returns a stored value or the supplied fallback

Parameters

string $key
mixed $default

Return Value

mixed

set

void set(string $key, mixed $value)

Stores a value through atomic session-file replacement

Parameters

string $key
mixed $value

Return Value

void

remove

void remove(string $key)

Removes a value and atomically persists the remaining payload

Parameters

string $key

Return Value

void

clear

void clear()

Clears the payload while retaining the current identity

Return Value

void

destroy

void destroy()

Deletes the active record, expires its cookie and releases its identity

Return Value

void

regenerate

void regenerate(bool $deleteOldSession = true)

Moves the payload to a new identity and optionally deletes the old record

Parameters

bool $deleteOldSession

Return Value

void