Store

class Store implements SessionInterface (View source)

Properties

protected string $id The session ID.
protected string $name The session name.
protected array $attributes The session attributes.
protected array $bags The session bags.
protected MetadataBag $metaBag The meta-data bag instance.
protected array $bagData Local copies of the session bag data.
protected SessionHandlerInterface $handler The session handler implementation.
protected bool $started Session store started status.

Methods

void __construct(string $name, SessionHandlerInterface $handler, string|null $id = null)

Create a new session instance.

start()

{@inheritdoc}

void loadSession()

Load the session data from the handler.

array readFromHandler()

Read the session data from the handler.

void initializeLocalBag(SessionBagInterface $bag)

Initialize a bag in storage if it doesn't exist.

getId()

{@inheritdoc}

setId($id)

{@inheritdoc}

bool isValidId(string $id)

Determine if this is a valid session ID.

string generateSessionId()

Get a new, random session ID.

getName()

{@inheritdoc}

setName($name)

{@inheritdoc}

invalidate($lifetime = null)

{@inheritdoc}

migrate($destroy = false, $lifetime = null)

{@inheritdoc}

bool regenerate(bool $destroy = false)

Generate a new session identifier.

save()

{@inheritdoc}

void addBagDataToSession()

Merge all of the bag data into the session.

void ageFlashData()

Age the flash data for the session.

has($name)

{@inheritdoc}

get($name, $default = null)

{@inheritdoc}

mixed pull(string $key, string $default = null)

Get the value of a given key and then forget it.

bool hasOldInput(string $key = null)

Determine if the session contains old input.

mixed getOldInput(string $key = null, mixed $default = null)

Get the requested item from the flashed input array.

set($name, $value)

{@inheritdoc}

void put(string|array $key, mixed|null $value = null)

Put a key / value pair or array of key / value pairs in the session.

void push(string $key, mixed $value)

Push a value onto a session array.

void flash(string $key, mixed $value)

Flash a key / value pair to the session.

void flashInput(array $value)

Flash an input array to the session.

void reflash()

Reflash all of the session flash data.

void keep(array|mixed $keys = null)

Reflash a subset of the current flash data.

void mergeNewFlashes(array $keys)

Merge new flash keys into the new flash array.

void removeFromOldFlashData(array $keys)

Remove the given keys from the old flash data.

all()

{@inheritdoc}

replace(array $attributes)

{@inheritdoc}

remove($name)

{@inheritdoc}

void forget(string $key)

Remove an item from the session.

clear()

{@inheritdoc}

void flush()

Remove all of the items from the session.

isStarted()

{@inheritdoc}

registerBag(SessionBagInterface $bag)

{@inheritdoc}

getBag($name)

{@inheritdoc}

getMetadataBag()

{@inheritdoc}

array getBagData(string $name)

Get the raw bag data array for a given bag.

string token()

Get the CSRF token value.

string getToken()

Get the CSRF token value.

void regenerateToken()

Regenerate the CSRF token value.

void setExists(bool $value)

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

SessionHandlerInterface getHandler()

Get the underlying session handler implementation.

bool handlerNeedsRequest()

Determine if the session handler needs a request.

void setRequestOnHandler(Request $request)

Set the request on the handler instance.

Details

void __construct(string $name, SessionHandlerInterface $handler, string|null $id = null)

Create a new session instance.

Parameters

string $name
SessionHandlerInterface $handler
string|null $id

Return Value

void

start()

{@inheritdoc}

protected void loadSession()

Load the session data from the handler.

Return Value

void

protected array readFromHandler()

Read the session data from the handler.

Return Value

array

protected void initializeLocalBag(SessionBagInterface $bag)

Initialize a bag in storage if it doesn't exist.

Parameters

SessionBagInterface $bag

Return Value

void

getId()

{@inheritdoc}

setId($id)

{@inheritdoc}

Parameters

$id

bool isValidId(string $id)

Determine if this is a valid session ID.

Parameters

string $id

Return Value

bool

protected string generateSessionId()

Get a new, random session ID.

Return Value

string

getName()

{@inheritdoc}

setName($name)

{@inheritdoc}

Parameters

$name

invalidate($lifetime = null)

{@inheritdoc}

Parameters

$lifetime

migrate($destroy = false, $lifetime = null)

{@inheritdoc}

Parameters

$destroy
$lifetime

bool regenerate(bool $destroy = false)

Generate a new session identifier.

Parameters

bool $destroy

Return Value

bool

save()

{@inheritdoc}

protected void addBagDataToSession()

Merge all of the bag data into the session.

Return Value

void

void ageFlashData()

Age the flash data for the session.

Return Value

void

has($name)

{@inheritdoc}

Parameters

$name

get($name, $default = null)

{@inheritdoc}

Parameters

$name
$default

mixed pull(string $key, string $default = null)

Get the value of a given key and then forget it.

Parameters

string $key
string $default

Return Value

mixed

bool hasOldInput(string $key = null)

Determine if the session contains old input.

Parameters

string $key

Return Value

bool

mixed getOldInput(string $key = null, mixed $default = null)

Get the requested item from the flashed input array.

Parameters

string $key
mixed $default

Return Value

mixed

set($name, $value)

{@inheritdoc}

Parameters

$name
$value

void put(string|array $key, mixed|null $value = null)

Put a key / value pair or array of key / value pairs in the session.

Parameters

string|array $key
mixed|null $value

Return Value

void

void push(string $key, mixed $value)

Push a value onto a session array.

Parameters

string $key
mixed $value

Return Value

void

void flash(string $key, mixed $value)

Flash a key / value pair to the session.

Parameters

string $key
mixed $value

Return Value

void

void flashInput(array $value)

Flash an input array to the session.

Parameters

array $value

Return Value

void

void reflash()

Reflash all of the session flash data.

Return Value

void

void keep(array|mixed $keys = null)

Reflash a subset of the current flash data.

Parameters

array|mixed $keys

Return Value

void

protected void mergeNewFlashes(array $keys)

Merge new flash keys into the new flash array.

Parameters

array $keys

Return Value

void

protected void removeFromOldFlashData(array $keys)

Remove the given keys from the old flash data.

Parameters

array $keys

Return Value

void

all()

{@inheritdoc}

replace(array $attributes)

{@inheritdoc}

Parameters

array $attributes

remove($name)

{@inheritdoc}

Parameters

$name

void forget(string $key)

Remove an item from the session.

Parameters

string $key

Return Value

void

clear()

{@inheritdoc}

void flush()

Remove all of the items from the session.

Return Value

void

isStarted()

{@inheritdoc}

registerBag(SessionBagInterface $bag)

{@inheritdoc}

Parameters

SessionBagInterface $bag

getBag($name)

{@inheritdoc}

Parameters

$name

getMetadataBag()

{@inheritdoc}

array getBagData(string $name)

Get the raw bag data array for a given bag.

Parameters

string $name

Return Value

array

string token()

Get the CSRF token value.

Return Value

string

string getToken()

Get the CSRF token value.

Return Value

string

void regenerateToken()

Regenerate the CSRF token value.

Return Value

void

void setExists(bool $value)

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

Parameters

bool $value

Return Value

void

SessionHandlerInterface getHandler()

Get the underlying session handler implementation.

bool handlerNeedsRequest()

Determine if the session handler needs a request.

Return Value

bool

void setRequestOnHandler(Request $request)

Set the request on the handler instance.

Parameters

Request $request

Return Value

void

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/4.2/Illuminate/Session/Store.html