Download the PHP package ronanchilvers/silex-sessions without Composer
On this page you can find all versions of the php package ronanchilvers/silex-sessions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ronanchilvers/silex-sessions
More information about ronanchilvers/silex-sessions
Files in ronanchilvers/silex-sessions
Package silex-sessions
Short Description Client side encrypted sessions for Silex
License MIT
Informations about the package silex-sessions
silex-sessions
cookie icon by Rashida Luqman Kheriwala from the Noun Project
This package provides client side, cookie based sessions for Silex. It is a standalone implementation and does not use Symfony's session mechanism. Session data is stored in a cookie allowing excellent horizontal scalability. The serialized data is encryption using defuse/php-encryption to ensure it is safe in the wild.
Installation
Installation is easy via composer:
Configuration
Firstly you need to add the service provider. There are various configuration options (detailed below) but you must at least provide an encryption key. See the key generation section below for details on creating a secure key.
Configuration options
There are various configuration options you can use, mostly to tweak the cookie storage the session uses. These are:
- cookie.name - The name of the session cookie
- cookie.expire - Expiry time for the cookie - by default when the browser closes
- cookie.path - The cookie path - '/' by default
- cookie.domain - The cookie domain - empty by default
- cookie.secure - Whether the session cookie should only be valid for HTTPS connections
- cookie.http.only - Whether the cookie should only be available via HTTP
- encryption.key - The secure encryption key to use for encrypting and decrypting the cookie payload
Usage
registers a couple of services on the container:
- A service, the standard session interface. This service has the usual , , and methods available.
- If you're using you'll also get a command to use for key generation. NB: Make sure that you register the console provider before the session provider.
Symfony Web Profiler Support
A data collector for the Symfony Web Profiler is included. To use it you need to first add the package to your project. Then enable the web profiler providers like so:
You should then start seeing a new button on the profiler toolbar and a new panel showing the session contents.
Encryption Key Generation
Generating a decently secure encryption key is important to maintain the security of the session data. This package provides a Symfony console command to generate and output an ASCII safe key which you can store in a config file. The console command is added automatically if you're using knplabs/console-service-provider.