UserFrosting API

Session implements ArrayAccess

A wrapper for $_SESSION that can be used with a variety of different session handlers, based on illuminate/session.

Tags
author

Alexander Weissman (https://alexanderweissman.com)

Table of Contents

$handler The session handler implementation. SessionHandlerInterface
__construct() Create the session wrapper. mixed
status() Returns the current session status. int
start() Start the session. mixed
destroy() Destroy the current session, and unset all values in memory. Destroy the session cookie as well to remove all traces client-side. mixed
regenerateId() Regenerate the session id. For example, when logging someone in, you should regenerate the session to prevent session fixation attacks. mixed
getId() Get the current session id. string
has() Determine if the given session value exists. bool
get() Get the specified session value. mixed
set() Set a given session value. mixed
setExists() Set the existence of the session on the handler if applicable. mixed
prepend() Prepend a value onto an array session value. mixed
push() Push a value onto an array session value. mixed
all() Get all of the session items for the application. array
offsetExists() Determine if the given session option exists. bool
offsetGet() Get a session option. mixed
offsetSet() Set a session option. mixed
offsetUnset() Unset a session option. mixed
getHandler() SessionHandlerInterface

Properties

$handler

The session handler implementation.

protected SessionHandlerInterface $handler

Methods

__construct()

Create the session wrapper.

public __construct( [ $handler : SessionHandlerInterface|null = null ] [, $config : array = [] ] ) : mixed
Parameters
$handler : SessionHandlerInterface|null = null
$config : array = []
Return values
mixed

status()

Returns the current session status.

public status( ) : int
Return values
int

PHP_SESSION_DISABLED | PHP_SESSION_NONE | PHP_SESSION_ACTIVE

start()

Start the session.

public start( ) : mixed
Return values
mixed

destroy()

Destroy the current session, and unset all values in memory. Destroy the session cookie as well to remove all traces client-side.

public destroy( [ $destroyCookie : bool = true ] ) : mixed
Parameters
$destroyCookie : bool = true

Destroy the cookie on the client side as well.

Return values
mixed

regenerateId()

Regenerate the session id. For example, when logging someone in, you should regenerate the session to prevent session fixation attacks.

public regenerateId( [ $deleteOldSession : bool = false ] ) : mixed
Parameters
$deleteOldSession : bool = false

Set to true when you are logging someone in.

Return values
mixed

getId()

Get the current session id.

public getId( ) : string
Return values
string

has()

Determine if the given session value exists.

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

get()

Get the specified session value.

public get( $key : string [, $default : mixed = null ] ) : mixed
Parameters
$key : string
$default : mixed = null
Return values
mixed

set()

Set a given session value.

public set( $key : array|string [, $value : mixed = null ] ) : mixed
Parameters
$key : array|string
$value : mixed = null
Return values
mixed

setExists()

Set the existence of the session on the handler if applicable.

public setExists( $value : bool ) : mixed
Parameters
$value : bool
Return values
mixed

prepend()

Prepend a value onto an array session value.

public prepend( $key : string , $value : mixed ) : mixed
Parameters
$key : string
$value : mixed
Return values
mixed

push()

Push a value onto an array session value.

public push( $key : string , $value : mixed ) : mixed
Parameters
$key : string
$value : mixed
Return values
mixed

all()

Get all of the session items for the application.

public all( ) : array
Return values
array

offsetExists()

Determine if the given session option exists.

public offsetExists( $key : string ) : bool
Parameters
$key : string
Return values
bool

offsetGet()

Get a session option.

public offsetGet( $key : string ) : mixed
Parameters
$key : string
Return values
mixed

offsetSet()

Set a session option.

public offsetSet( $key : string , $value : mixed ) : mixed
Parameters
$key : string
$value : mixed
Return values
mixed

offsetUnset()

Unset a session option.

public offsetUnset( $key : string ) : mixed
Parameters
$key : string
Return values
mixed

getHandler()

public getHandler( ) : SessionHandlerInterface
Return values
SessionHandlerInterface

Search results