@@ -10,21 +10,80 @@ composer require rancoud/session
1010```
1111
1212## How to use it?
13+ The most popular
1314``` php
15+ Session::set('key', 'value');
16+ $value = Session::get('key');
17+ ```
18+ In read only
19+ ``` php
20+ Session::readOnly();
21+ Session::set('key', 'value');
22+ $value = Session::get('key');
23+ ```
24+ With custom options
25+ ``` php
26+ Session::start(['read_and_close' => true]);
27+ Session::set('key', 'value');
28+ $value = Session::get('key');
29+ ```
30+ With encryption on default php session
31+ ``` php
32+ Session::useDefaultEncryptionDriver('keyForEncryption');
33+ Session::set('key', 'value');
34+ $value = Session::get('key');
35+ ```
36+ With File driver
37+ ``` php
38+ Session::useFileDriver();
39+ Session::set('key', 'value');
40+ $value = Session::get('key');
41+ ```
42+ With Database driver (you have to install rancoud/database)
43+ ``` php
44+ $conf = new \Rancoud\Database\Configurator([
45+ 'engine' => 'mysql',
46+ 'host' => '127.0.0.1',
47+ 'user' => 'root',
48+ 'password' => '',
49+ 'database' => 'test_database'
50+ ]);
51+ $db = new \Rancoud\Database\Database($conf);
52+
53+ // for using a current connection
54+ Session::useCurrentDatabaseDriver($db);
55+
56+ // for creating a new connection
57+ //Session::useNewDatabaseDriver($conf);
1458
59+ Session::set('key', 'value');
60+ $value = Session::get('key');
1561```
62+ With Redis driver (you have to install predis/predis)
63+ ``` php
64+ $params = [
65+ 'scheme' => 'tcp',
66+ 'host' => '127.0.0.1',
67+ 'port' => 6379,
68+ ];
69+ $redis = new Predis\Client($params);
1670
17- ## Session Constructor
18- ### Settings
19- #### Mandatory
20- | Parameter | Type | Description |
21- | --- | --- | --- |
22- | | | |
71+ // for using a current connection
72+ Session::useCurrentRedisDriver($redis);
2373
24- #### Optionnals
25- | Parameter | Type | Default value | Description |
26- | --- | --- | --- | --- |
27- | | | | |
74+ // for creating a new connection
75+ //Session::useNewRedisDriver($params);
76+
77+ Session::set('key', 'value');
78+ $value = Session::get('key');
79+ ```
80+ With your own driver implementing SessionHandlerInterface
81+ ``` php
82+ $driver = new MyCustomDriver();
83+ Session::useCustomDriver($driver);
84+ Session::set('key', 'value');
85+ $value = Session::get('key');
86+ ```
2887
2988## Session Methods
3089### General Commands
@@ -37,7 +96,7 @@ Extends SessionHandler
3796## Database
3897You need to install
3998``` php
40- composer require rancoud/session
99+ composer require rancoud/database
41100```
42101``` sql
43102CREATE TABLE IF NOT EXISTS ` sessions` (
0 commit comments