1. Go to this page and download the library: Download byjg/jwt-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/ */
byjg / jwt-session example snippets
$sessionConfig = (new \ByJG\Session\SessionConfig('your.domain.com'))
->withSecret('your super base64url encoded secret key');
$handler = new \ByJG\Session\JwtSession($sessionConfig);
session_set_save_handler($handler, true);
$sessionConfig = (new \ByJG\Session\SessionConfig('your.domain.com'))
->withSecret('your super base64url encoded secret key')
->withTimeoutMinutes(60); // You can use withTimeoutHours(1)
$handler = new \ByJG\Session\JwtSession($sessionConfig);
session_set_save_handler($handler, true);
$sessionConfig = (new \ByJG\Session\SessionConfig('your.domain.com'))
->withSecret('your super base64url encoded secret key')
->withSessionContext('MYCONTEXT');
$handler = new \ByJG\Session\JwtSession($sessionConfig);
session_set_save_handler($handler, true);
$sessionConfig = (new \ByJG\Session\SessionConfig('your.domain.com'))
->withSecret('your super base64url encoded secret key')
->replaceSessionHandler();
$handler = new \ByJG\Session\JwtSession($sessionConfig);
$sessionConfig = (new \ByJG\Session\SessionConfig('your.domain.com'))
->withSecret('your super base64url encoded secret key')
->withCookie('.mydomain.com', '/')
->replaceSessionHandler();
$handler = new \ByJG\Session\JwtSession($sessionConfig);