1. Go to this page and download the library: Download ujjwal/psr7-http-session 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/ */
ujjwal / psr7-http-session example snippets
$sessionOptions = [
'name' => 'session_id',
'sid_length' => 40,
'cookie' => [
'domain' => 'your-app.com',
]
];
$sessionHandler = new Ojhaujjwal\Session\Handler\FileHandler('path/to/session-data');
$sessionManager = new Ojhaujjwal\Session\SessionManager(
$sessionHandler,
$request,
$sessionOptions
);
$storage = $sessionManager->getStorage();
$sessionManager->start();
// you can manipulate $storage just like $_SESSION
$storage['some_key'] = 'some_value';
$someKey = $storage['some_key'];
$response = $sessionManager->close($response);
//return the response the the client
$sessionManager = new Ojhaujjwal\Session\SessionManager(
$sessionHandler,
$request,
$sessionOptions
);
$middleware = new Ojhaujjwal\Session\SessionMiddleware($handler, $sessionOptions);
$middleware->process($request, $delegate);
// or
$middleware($request, $response, $next);
//using with zend-expressive
//after errorhandler and before the routing middleware
$app->pipe(\Ojhaujjwal\Session\SessionMiddleware::class);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.