PHP code example of ellipse / session-validation
1. Go to this page and download the library: Download ellipse/session-validation 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/ */
ellipse / session-validation example snippets
namespace App;
use Psr\Http\Message\ServerRequestInterface;
use Ellipse\Session\ValidateSessionMiddleware;
// This callable must return an associative array.
$signature = function (ServerRequestInterface $request) {
// Here we assume another middleware set the client ip attribute of the request.
return [
'client-ip' => $request->getAttribute('client-ip'),
];
};
// When using this middleware the session data are tied to the client ip address.
// Any attempt to access the session data with a different client ip address would
// invalidate the client session. Obvioulsy this middleware should only be processed
// after the session has started.
$middleware = new ValidateSessionMiddleware($signature);