1. Go to this page and download the library: Download snicco/session-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
//path/to/config/middleware.php
use Snicco\Bundle\HttpRouting\Option\MiddlewareOption;
use Snicco\Bundle\Session\Middleware\AllowMutableSessionForReadVerbs;
use Snicco\Bundle\Session\Middleware\SaveResponseAttributes;
use Snicco\Bundle\Session\Middleware\SessionNoCache;
use Snicco\Bundle\Session\Middleware\ShareSessionWithViews;
use Snicco\Bundle\Session\Middleware\StatefulRequest;
return [
MiddlewareOption::GROUPS => [
'stateful' => [
StatefulRequest::class,
ShareSessionWithViews::class,
SaveResponseAttributes::class,
// SessionNoCache::class, optional
]
],
MiddlewareOption::ALIASES => [
'session-allow-write' => AllowMutableSessionForReadVerbs::class,
'session-no-cache' => SessionNoCache::class,
]
];
// inside a controller or middleware
use Snicco\Component\Session\ImmutableSession;
use Snicco\Component\Session\MutableSession;
$request->getAttribute(ImmutableSession::class);
// Only for unsafe request methods or if allowed explicitly for read requests.
$request->getAttribute(MutableSession::class);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.