1
1
# JwtSession
2
2
3
+ [ ![ Opensource ByJG] ( https://img.shields.io/badge/opensource-byjg.com-brightgreen.svg )] ( http://opensource.byjg.com )
3
4
[ ![ Build Status] ( https://travis-ci.org/byjg/jwt-session.svg?branch=master )] ( https://travis-ci.org/byjg/jwt-session )
4
5
[ ![ 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 )
5
6
6
7
JwtSession is a PHP session replacement. Instead of use FileSystem, just use JWT TOKEN.
7
8
The implementation following the SessionHandlerInterface.
8
9
9
- ## How to use:
10
+ # How to use:
10
11
11
12
Before the session_start() use the command:
12
13
@@ -18,7 +19,7 @@ session_set_save_handler($handler, true);
18
19
19
20
Now, all your ` $_SESSION ` variable will be saved directly to a JWT Token!!
20
21
21
- ## Motivation
22
+ # Motivation
22
23
23
24
The default PHP Session does not work in different servers using round robin or other algorithms.
24
25
This 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.
39
40
This implementation save the JWT into a client cookie.
40
41
Because of this _ ** do not** store in the JWT Token sensible data like passwords_ .
41
42
42
- ## Install
43
+ # Install
43
44
44
45
```
45
46
composer require "byjg/jwt-session=1.0.*"
46
47
```
47
48
48
- ## Customizations
49
+ # Customizations
49
50
50
- ### Setting the validity of JWT Token
51
+ ## Setting the validity of JWT Token
51
52
52
53
``` php
53
54
<?php
@@ -56,31 +57,33 @@ $handler = new \ByJG\Session\JwtSession('your.domain.com', 'your super secret ke
56
57
session_set_save_handler($handler, true);
57
58
```
58
59
59
- ### Setting the different Session Contexts
60
+ ## Setting the different Session Contexts
60
61
61
62
``` php
62
63
<?php
63
64
$handler = new \ByJG\Session\JwtSession('your.domain.com', 'your super secret key', 20, 'MYCONTEXT');
64
65
session_set_save_handler($handler, true);
65
66
```
66
67
67
- ### Create the handler and replace the session handler
68
+ ## Create the handler and replace the session handler
68
69
69
70
``` php
70
71
<?php
71
72
$handler = new \ByJG\Session\JwtSession('your.domain.com', 'your super secret key');
72
73
$handler->replaceSessionHandler(true);
73
74
```
74
75
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
76
77
77
78
``` php
78
79
<?php
79
80
$handler = new \ByJG\Session\JwtSession('your.domain.com', 'your super secret key', null, null, '.mydomain.com');
80
81
$handler->replaceSessionHandler(true);
81
82
```
82
83
83
- ### How it works
84
+ ## How it works
84
85
85
86
We 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