Leaf PHP

Session
in package

Leaf Session ---------------- App session management made simple with Leaf

Tags
author

Michael Darko

since
1.5.0

Table of Contents

Methods

all()  : array<string|int, mixed>
Get all session variables as an array
body()  : array<string|int, mixed>
Get all session variables as an array
clear()  : mixed
Remove all session variables
decode()  : bool
Decodes session data from a string
delete()  : mixed
Alias for unset
destroy()  : mixed
End the current session
encode()  : string
Encodes the current session data as a string
flash()  : mixed
Set or get a flash message
get()  : mixed
Get a session variable
has()  : bool
Has Session Item
id()  : string
Get the current session id: will set the session id if none is found
regenerate()  : bool
Regenerate the session id/Generate a new session if none exists
remove()  : mixed
Remove a session variable
reset()  : mixed
Reset the current session
retrieve()  : mixed
Returns the requested value and removes it from the session
set()  : void
Set a new session variable
start()  : mixed
Start a session if one isn't already started
unset()  : mixed
Remove a session variable
unsetSessionVar()  : mixed
Remove a session variable

Methods

all()

Get all session variables as an array

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

body()

Get all session variables as an array

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

array of session variables

clear()

Remove all session variables

public static clear() : mixed

decode()

Decodes session data from a string

public static decode(mixed $data) : bool
Parameters
$data : mixed
Return values
bool

delete()

Alias for unset

public static delete(mixed $key) : mixed
Parameters
$key : mixed

destroy()

End the current session

public static destroy() : mixed

encode()

Encodes the current session data as a string

public static encode() : string
Return values
string

flash()

Set or get a flash message

public static flash([string|null $message = null ]) : mixed
Parameters
$message : string|null = null

The flash message

get()

Get a session variable

public static get(string|array<string|int, mixed> $param[, mixed $default = null ][, bool $sanitize = true ]) : mixed
Parameters
$param : string|array<string|int, mixed>

The session variable to get

$default : mixed = null

The default value to return if the requested value cannot be found

$sanitize : bool = true

Sanitize the data before returning it?

has()

Has Session Item

public static has(mixed $key) : bool
Parameters
$key : mixed
Return values
bool

id()

Get the current session id: will set the session id if none is found

public static id([string $id = null ]) : string
Parameters
$id : string = null

id to override the default

Return values
string

regenerate()

Regenerate the session id/Generate a new session if none exists

public static regenerate([bool $clearData = false ]) : bool
Parameters
$clearData : bool = false

Clear all session data?

Return values
bool

True on success, false on failure

remove()

Remove a session variable

public static remove(mixed $key) : mixed
Parameters
$key : mixed

reset()

Reset the current session

public static reset([string $id = null ]) : mixed
Parameters
$id : string = null

id to overwrite the default

retrieve()

Returns the requested value and removes it from the session

public static retrieve(string $key[, mixed $default = null ][, bool $sanitize = true ]) : mixed

This is identical to calling get first and then unset for the same key

Parameters
$key : string

the key to retrieve and remove the value for

$default : mixed = null
$sanitize : bool = true

Whether to sanitize the returned value

Return values
mixed

the requested value or the default value

set()

Set a new session variable

public static set(mixed $key[, mixed $value = null ]) : void
Parameters
$key : mixed

: The session variable key

$value : mixed = null

: The session variable value

start()

Start a session if one isn't already started

public static start() : mixed

unset()

Remove a session variable

public static unset(string $key) : mixed
Parameters
$key : string

: The session variable key

unsetSessionVar()

Remove a session variable

protected static unsetSessionVar(mixed $key) : mixed
Parameters
$key : mixed

        
On this page

Search results