11# JwtSession
22
3+ [ ![ Opensource ByJG] ( https://img.shields.io/badge/opensource-byjg.com-brightgreen.svg )] ( http://opensource.byjg.com )
34[ ![ Build Status] ( https://travis-ci.org/byjg/jwt-session.svg?branch=master )] ( https://travis-ci.org/byjg/jwt-session )
45[ ![ Scrutinizer Code Quality] ( https://scrutinizer-ci.com/g/byjg/jwt-session/badges/quality-score.png?b=master )] ( https://scrutinizer-ci.com/g/byjg/jwt-session/?branch=master )
56
67JwtSession is a PHP session replacement. Instead of use FileSystem, just use JWT TOKEN.
78The implementation following the SessionHandlerInterface.
89
9- ## How to use:
10+ # How to use:
1011
1112Before the session_start() use the command:
1213
@@ -18,7 +19,7 @@ session_set_save_handler($handler, true);
1819
1920Now, all your ` $_SESSION ` variable will be saved directly to a JWT Token!!
2021
21- ## Motivation
22+ # Motivation
2223
2324The default PHP Session does not work in different servers using round robin or other algorithms.
2425This occurs because PHP Session are saved by default in the file system.
@@ -39,15 +40,15 @@ The JWT Token cannot be changed, but it can be read.
3940This implementation save the JWT into a client cookie.
4041Because of this _ ** do not** store in the JWT Token sensible data like passwords_ .
4142
42- ## Install
43+ # Install
4344
4445```
4546composer require "byjg/jwt-session=1.0.*"
4647```
4748
48- ## Customizations
49+ # Customizations
4950
50- ### Setting the validity of JWT Token
51+ ## Setting the validity of JWT Token
5152
5253``` php
5354<?php
@@ -56,31 +57,33 @@ $handler = new \ByJG\Session\JwtSession('your.domain.com', 'your super secret ke
5657session_set_save_handler($handler, true);
5758```
5859
59- ### Setting the different Session Contexts
60+ ## Setting the different Session Contexts
6061
6162``` php
6263<?php
6364$handler = new \ByJG\Session\JwtSession('your.domain.com', 'your super secret key', 20, 'MYCONTEXT');
6465session_set_save_handler($handler, true);
6566```
6667
67- ### Create the handler and replace the session handler
68+ ## Create the handler and replace the session handler
6869
6970``` php
7071<?php
7172$handler = new \ByJG\Session\JwtSession('your.domain.com', 'your super secret key');
7273$handler->replaceSessionHandler(true);
7374```
7475
75- ### Create the handler and replace the session handler, specifying cookie domain valid for all subdomains of mydomain.com
76+ ## Create the handler and replace the session handler, specifying cookie domain valid for all subdomains of mydomain.com
7677
7778``` php
7879<?php
7980$handler = new \ByJG\Session\JwtSession('your.domain.com', 'your super secret key', null, null, '.mydomain.com');
8081$handler->replaceSessionHandler(true);
8182```
8283
83- ### How it works
84+ ## How it works
8485
8586We store a cookie named AUTH_BEARER_ <context name > with the session name. The PHPSESSID cookie is still created because
86- PHP create it by default but we do not use it;
87+ PHP create it by default but we do not use it;
88+
89+
0 commit comments