Documentation

Session
in package
implements SessionInterface, IteratorAggregate, Countable

Tags
author

Fabien Potencier fabien@symfony.com

author

Drak drak@zikula.org

implements

\IteratorAggregate<string, mixed>

Interfaces, Classes and Traits

SessionInterface
Interface for the session.
IteratorAggregate
Countable

Table of Contents

$storage  : mixed
$attributeName  : mixed
$data  : mixed
$flashName  : mixed
$usageIndex  : mixed
$usageReporter  : mixed
__construct()  : mixed
all()  : array<string|int, mixed>
Returns attributes.
clear()  : mixed
Clears all attributes.
count()  : int
Returns the number of attributes.
get()  : mixed
Returns an attribute.
getBag()  : SessionBagInterface
Gets a bag instance by name.
getFlashBag()  : FlashBagInterface
Gets the flashbag interface.
getId()  : string
Returns the session ID.
getIterator()  : ArrayIterator<string, mixed>
Returns an iterator for attributes.
getMetadataBag()  : MetadataBag
Gets session meta.
getName()  : string
Returns the session name.
getUsageIndex()  : int
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.
getAttributeBag()  : AttributeBagInterface
Gets the attributebag interface.

Properties

$attributeName

private mixed $attributeName

$usageIndex

private mixed $usageIndex = 0

$usageReporter

private mixed $usageReporter

Methods

all()

Returns attributes.

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

clear()

Clears all attributes.

public clear() : mixed
Return values
mixed

count()

Returns the number of attributes.

public count() : int
Return values
int

get()

Returns an attribute.

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

The default value if not found

Return values
mixed

getId()

Returns the session ID.

public getId() : string
Return values
string

getIterator()

Returns an iterator for attributes.

public getIterator() : ArrayIterator<string, mixed>
Return values
ArrayIterator<string, mixed>

getName()

Returns the session name.

public getName() : string
Return values
string

getUsageIndex()

public getUsageIndex() : int
Return values
int

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|null $lifetime = null ]) : bool
Parameters
$lifetime : int|null = 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|null $lifetime = null ]) : bool
Parameters
$destroy : bool = false

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

$lifetime : int|null = 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>
Return values
mixed

save()

Force the session to be saved and closed.

public save() : mixed
Return values
mixed

set()

Sets an attribute.

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

setId()

Sets the session ID.

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

setName()

Sets the session name.

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

start()

Starts the session storage.

public start() : bool
Return values
bool

Search results