Documentation

Session extends Session
in package

Class Session

Table of Contents

Properties

$autoStart  : bool
$instance  : Session
$options  : array<string|int, mixed>
$started  : bool

Methods

__construct()  : mixed
Session constructor.
__get()  : mixed
Returns session variable.
__isset()  : bool
Checks if session variable is defined.
__set()  : void
Sets session variable.
__unset()  : void
Removes session variable.
all()  : array<string|int, mixed>
Returns attributes.
clear()  : $this
Free all session variables.
close()  : $this
Force the session to be saved and closed
getAll()  : array<string|int, mixed>
Returns all session variables.
getCookieOptions()  : array<string|int, mixed>
Store something in cookie temporarily.
getFlashCookieObject()  : mixed|null
Return object and remove it from the cookie.
getFlashObject()  : mixed
Return object and remove it from session.
getId()  : string|null
Get session ID
getInstance()  : Session
Get current session instance.
getIterator()  : ArrayIterator
Retrieve an external iterator
getName()  : string|null
Get session name
init()  : void
Initialize session.
instance()  : Session
invalidate()  : $this
Invalidates the current session.
isStarted()  : bool
Checks if the session was started.
regenerateId()  : $this
Regenerate session id but keep the current session information.
setAutoStart()  : $this
setFlashCookieObject()  : $this
Store something in cookie temporarily.
setFlashObject()  : $this
Store something in session temporarily.
setId()  : $this
Set session ID
setName()  : $this
Set session name
setOptions()  : void
Sets session.* ini variables.
start()  : $this
Starts the session storage
started()  : bool
Checks if the session was started.
isSessionStarted()  : bool
http://php.net/manual/en/function.session-status.php#113468 Check if session is started nicely.
onBeforeSessionStart()  : void
onSessionStart()  : void
removeCookie()  : void
setCookie()  : void
setOption()  : void

Properties

$autoStart

protected bool $autoStart = false

$options

protected array<string|int, mixed> $options = []

$started

protected bool $started = false

Methods

__construct()

Session constructor.

public __construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
$options : array<string|int, mixed> = []

__get()

Returns session variable.

public __get(mixed $name) : mixed
Parameters
$name : mixed
Tags
inheritdoc
Attributes
#[ReturnTypeWillChange]

__isset()

Checks if session variable is defined.

public __isset(mixed $name) : bool
Parameters
$name : mixed
Tags
inheritdoc
Attributes
#[ReturnTypeWillChange]
Return values
bool

__set()

Sets session variable.

public __set(mixed $name, mixed $value) : void
Parameters
$name : mixed
$value : mixed
Tags
inheritdoc
Attributes
#[ReturnTypeWillChange]

__unset()

Removes session variable.

public __unset(mixed $name) : void
Parameters
$name : mixed
Tags
inheritdoc
Attributes
#[ReturnTypeWillChange]

all()

Returns attributes.

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

Use ->getAll() method instead.

Return values
array<string|int, mixed>

Attributes

clear()

Free all session variables.

public clear() : $this
Tags
inheritdoc
Return values
$this

close()

Force the session to be saved and closed

public close() : $this
Tags
inheritdoc
Return values
$this

getAll()

Returns all session variables.

public getAll() : array<string|int, mixed>
Tags
inheritdoc
Return values
array<string|int, mixed>

getCookieOptions()

Store something in cookie temporarily.

public getCookieOptions([int|null $lifetime = null ]) : array<string|int, mixed>
Parameters
$lifetime : int|null = null
Return values
array<string|int, mixed>

getFlashCookieObject()

Return object and remove it from the cookie.

public getFlashCookieObject(string $name) : mixed|null
Parameters
$name : string
Tags
throws
JsonException
Return values
mixed|null

getFlashObject()

Return object and remove it from session.

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

getId()

Get session ID

public getId() : string|null
Tags
inheritdoc
Return values
string|null

Session ID

getInstance()

Get current session instance.

public static getInstance() : Session
Tags
inheritdoc
Return values
Session

getIterator()

Retrieve an external iterator

public getIterator() : ArrayIterator
Tags
inheritdoc
Attributes
#[ReturnTypeWillChange]
Return values
ArrayIterator

Return an ArrayIterator of $_SESSION

getName()

Get session name

public getName() : string|null
Tags
inheritdoc
Return values
string|null

init()

Initialize session.

public init() : void

Code in this function has been moved into SessionServiceProvider class.

invalidate()

Invalidates the current session.

public invalidate() : $this
Tags
inheritdoc
Return values
$this

isStarted()

Checks if the session was started.

public isStarted() : bool
Tags
inheritdoc
Return values
bool

regenerateId()

Regenerate session id but keep the current session information.

public regenerateId() : $this

Session id must be regenerated on login, logout or after long time has been passed.

Tags
since
1.7
Return values
$this

setAutoStart()

public setAutoStart(bool $auto) : $this
Parameters
$auto : bool
Return values
$this

setFlashCookieObject()

Store something in cookie temporarily.

public setFlashCookieObject(string $name, mixed $object[, int $time = 60 ]) : $this
Parameters
$name : string
$object : mixed
$time : int = 60
Tags
throws
JsonException
Return values
$this

setFlashObject()

Store something in session temporarily.

public setFlashObject(string $name, mixed $object) : $this
Parameters
$name : string
$object : mixed
Return values
$this

setId()

Set session ID

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

Session ID

Tags
inheritdoc
Return values
$this

setName()

Set session name

public setName(mixed $name) : $this
Parameters
$name : mixed
Tags
inheritdoc
Return values
$this

setOptions()

Sets session.* ini variables.

public setOptions(array<string|int, mixed> $options) : void
Parameters
$options : array<string|int, mixed>
Tags
inheritdoc

start()

Starts the session storage

public start([mixed $readonly = false ]) : $this
Parameters
$readonly : mixed = false
Tags
inheritdoc
Return values
$this

started()

Checks if the session was started.

public started() : bool

Use ->isStarted() method instead.

Return values
bool

isSessionStarted()

http://php.net/manual/en/function.session-status.php#113468 Check if session is started nicely.

protected isSessionStarted() : bool
Return values
bool

onBeforeSessionStart()

protected onBeforeSessionStart() : void

onSessionStart()

protected onSessionStart() : void

removeCookie()

protected removeCookie() : void

setCookie()

protected setCookie() : void

setOption()

protected setOption(string $key, mixed $value) : void
Parameters
$key : string
$value : mixed

        
On this page

Search results