Documentation

SessionInterface

Interface for the session.

Tags
author

Drak drak@zikula.org

Table of Contents

Methods

all()  : array<string|int, mixed>
Returns attributes.
clear()  : mixed
Clears all attributes.
get()  : mixed
Returns an attribute.
getBag()  : SessionBagInterface
Gets a bag instance by name.
getId()  : string
Returns the session ID.
getMetadataBag()  : MetadataBag
Gets session meta.
getName()  : string
Returns the session name.
has()  : bool
Checks if an attribute is defined.
invalidate()  : bool
Invalidates the current session.
isStarted()  : bool
Checks if the session was started.
migrate()  : bool
Migrates the current session to a new session id while maintaining all session attributes.
registerBag()  : mixed
Registers a SessionBagInterface with the session.
remove()  : mixed
Removes an attribute.
replace()  : mixed
Sets attributes.
save()  : mixed
Force the session to be saved and closed.
set()  : mixed
Sets an attribute.
setId()  : mixed
Sets the session ID.
setName()  : mixed
Sets the session name.
start()  : bool
Starts the session storage.

Methods

all()

Returns attributes.

public all() : array<string|int, mixed>
Return values
array<string|int, mixed>

get()

Returns an attribute.

public get(string $name[, mixed $default = null ]) : mixed
Parameters
$name : string
$default : mixed = null

getId()

Returns the session ID.

public getId() : string
Return values
string

getName()

Returns the session name.

public getName() : string
Return values
string

has()

Checks if an attribute is defined.

public has(string $name) : bool
Parameters
$name : string
Return values
bool

invalidate()

Invalidates the current session.

public invalidate([int $lifetime = null ]) : bool

Clears all session attributes and flashes and regenerates the session and deletes the old session from persistence.

Parameters
$lifetime : int = null

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 values
bool

isStarted()

Checks if the session was started.

public isStarted() : bool
Return values
bool

migrate()

Migrates the current session to a new session id while maintaining all session attributes.

public migrate([bool $destroy = false ][, int $lifetime = null ]) : bool
Parameters
$destroy : bool = false

Whether to delete the old session or leave it to garbage collection

$lifetime : int = null

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 values
bool

remove()

Removes an attribute.

public remove(string $name) : mixed
Parameters
$name : string
Return values
mixed

The removed value or null when it does not exist

replace()

Sets attributes.

public replace(array<string|int, mixed> $attributes) : mixed
Parameters
$attributes : array<string|int, mixed>

save()

Force the session to be saved and closed.

public save() : mixed

This method is generally not required for real sessions as the session will be automatically saved at the end of code execution.

set()

Sets an attribute.

public set(string $name, mixed $value) : mixed
Parameters
$name : string
$value : mixed

setId()

Sets the session ID.

public setId(string $id) : mixed
Parameters
$id : string

setName()

Sets the session name.

public setName(string $name) : mixed
Parameters
$name : string

start()

Starts the session storage.

public start() : bool
Tags
throws
RuntimeException

if session fails to start

Return values
bool

        
On this page

Search results