FileSessionStorage
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
Defines private storage, retention, cookie identity and bounded garbage collection
Loads an existing session or creates a new identity
Reports whether the session has started during this request
Checks whether a value exists, including an explicit null
Returns a stored value or the supplied fallback
Stores a value through atomic session-file replacement
Removes a value and atomically persists the remaining payload
Clears the payload while retaining the current identity
Deletes the active record, expires its cookie and releases its identity
Moves the payload to a new identity and optionally deletes the old record
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
start
void
start()
Loads an existing session or creates a new identity
started
bool
started()
Reports whether the session has started during this request
has
bool
has(string $key)
Checks whether a value exists, including an explicit null
get
mixed
get(string $key, mixed $default = null)
Returns a stored value or the supplied fallback
set
void
set(string $key, mixed $value)
Stores a value through atomic session-file replacement
remove
void
remove(string $key)
Removes a value and atomically persists the remaining payload
clear
void
clear()
Clears the payload while retaining the current identity
destroy
void
destroy()
Deletes the active record, expires its cookie and releases its identity
regenerate
void
regenerate(bool $deleteOldSession = true)
Moves the payload to a new identity and optionally deletes the old record