Download the PHP package davidecesarano/embryo-session without Composer
On this page you can find all versions of the php package davidecesarano/embryo-session. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download davidecesarano/embryo-session
More information about davidecesarano/embryo-session
Files in davidecesarano/embryo-session
Package embryo-session
Short Description PSR-15 middleware to create a php session using the PSR-7 request.
License MIT
Homepage https://github.com/davidecesarano/embryo-session
Informations about the package embryo-session
Embryo Session
Middleware to start a php session using the request data and close it after return the response.
Requirements
- PHP >= 7.1
- A PSR-7 http message implementation and PSR-17 http factory implementation (ex. Embryo-Http)
- A PSR-15 http server request implementation (ex. Embryo-Middleware)
Installation
Using Composer:
Usage
Creates a middleware for setting session item:
Creates another middleware for getting session item:
Adds middleware to dispatcher:
Options
setName(string $name)
The session name. If it's not provided, use the php's default.
seOptions(array $options = [])
Array of options passed to session_start()
.
setSessionRequestAttribute(string $name)
The session request attribute. If it's not provided, use $request->getAttribute('session')
.
Collection
Retrieving data
You may retrieve an item from the session and you may also pass a default value as the second argument to the get
method:
Retrieving all session data
If you would like to retrieve all the data in the session, you may use the all
method:
Determining if an item exists in the session
To determine if an item is present in the session, you may use the has
method. The has method returns true
if the item is present and is not null
:
Storing data
The set
method may be used to set a new value onto a session:
Flash data
You may wish to store items in the session only for the next request using the flash
method:
Deleting data
The remove
method will remove a piece of data from the session. If you would like the remove all data from the session, you may use the clear
method:
All versions of embryo-session with dependencies
davidecesarano/embryo-http Version dev-master
davidecesarano/embryo-middleware Version dev-master
davidecesarano/embryo-emitter Version dev-master