@@ -10,11 +10,10 @@ Koded Session
1010
1111
1212The library relies on the ` php.ini ` settings.
13- Every session ini directive can be reset in the
14- configuration object.
13+ Every session ini directive can be reset with the
14+ ` Koded\Session\SessionConfiguration ` object.
1515
1616Refer to php.ini session directives:
17-
1817http://php.net/manual/en/session.security.ini.php
1918
2019
@@ -51,8 +50,8 @@ session()->set('key', 'value');
5150// etc.
5251```
5352
54- The session class can be instantiated and used, but function ` session() `
55- is much preferred instead an instance of ` Session ` class.
53+ The session class can be instantiated and used, but the function ` session() `
54+ is recommended instead an instance of ` Session ` class.
5655
5756
5857Handlers Configuration
@@ -63,7 +62,7 @@ The bare minimum is to define the handler you want to use for the session:
6362``` php
6463// in your configuration file
6564
66- [
65+ return [
6766 'session' => [
6867 'save_handler' => 'redis | memcache'
6968 ]
@@ -73,11 +72,10 @@ The bare minimum is to define the handler you want to use for the session:
7372If you do not choose one of the Redis or Memcached, it defaults to ` files `
7473handler which is the PHP's default session mechanism.
7574
76- However, the ` files ` handler might not be a desirable if your application
77- runs in Docker, Kubernetes or otherwise horizontal scaled setup,
78- distributed environment, etc.
75+ However, the ` files ` handler might not be desirable if your application
76+ runs in Docker, Kubernetes, distributed environment, etc.
7977
80- The best choice is Redis in almost all situations.
78+ The best choice for PHP sessions is Redis in almost all situations.
8179
8280WARNING: Memcached may drop the session data, because it's nature. Use it with caution!
8381
@@ -89,16 +87,14 @@ Redis handler
8987 'session' => [
9088 'save_handler' => 'redis'
9189
92- // OPTIONAL:
93- // these are the defaults
94- 'prefix' => 'sess:',
95-
90+ // OPTIONAL, these are the defaults
9691 'host' => 'localhost',
9792 'port' => 6379,
9893 'timeout' => 0.0,
9994 'retry' => 0,
10095 'db' => 0,
10196
97+ 'prefix' => 'sess:',
10298 'serializer' => 'php', // or "json"
10399 'binary' => false, // TRUE for igbinary
104100 ]
@@ -107,8 +103,8 @@ Redis handler
107103
108104A typical Redis settings:
109105- 1 server
110- - application
111- - Redis (localhost :6379)
106+ - application + redis on the same machine
107+ - Redis (127.0.0.1 :6379)
112108- no auth (Redis is not available from outside)
113109
114110``` php
@@ -136,17 +132,16 @@ Memcached handler
136132 'session' => [
137133 'save_handler' => 'memcached',
138134
139- // OPTIONAL:
140- // If you have multi memcached servers,
141- // defaults to ['127.0.0.1', 11211]
135+ // OPTIONAL: defaults to ['127.0.0.1', 11211]
136+ // If you have multiple memcached servers
142137 'servers' => [
143138 ['127.0.0.1', 11211],
144139 ['127.0.0.1', 11212],
145140 ['127.0.0.2']
146141 ...
147142 ],
148143
149- // the options are optional
144+ // OPTIONAL: the options are not mandatory
150145 'options' => [
151146 ...
152147 ]
@@ -156,8 +151,8 @@ Memcached handler
156151
157152A typical Memcached settings:
158153- 1 server
159- - application
160- - Memcached (localhost :11211)
154+ - application + memcached on the same machine
155+ - Memcached (127.0.0.1 :11211)
161156
162157``` php
163158[
@@ -169,9 +164,8 @@ A typical Memcached settings:
169164]
170165```
171166
172- To support huge amount of sessions you need a decent amounts of RAM
173- on your server(s).
174- But Memcached is a master technology for this, so you should be fine.
167+ To support huge amount of users you need a decent amounts of RAM
168+ on your servers. But Memcached is a master technology for this, so you should be fine.
175169
176170
177171Files handler
@@ -180,14 +174,13 @@ Files handler
180174This one is not recommended for any serious business.
181175It's fine only for small projects.
182176
183- All session directives are defined in ` php.ini ` .
177+ All session directives are copied from ` php.ini ` .
184178
185179``` php
186180[
187181 'session' => [
188- // OPTIONAL:
189- // the path where to store the session data,
190- // defaults to "session_save_path()"
182+ // OPTIONAL: defaults to "session_save_path()"
183+ // the path where to store the session data
191184 'save_path' => '/var/www/sessions',
192185 'serialize_handler' => 'php'
193186 ]
@@ -206,6 +199,6 @@ A typical native PHP session settings:
206199```
207200
208201You cannot use this handler if you've scaled your application,
209- because the session data will be handled on different instance
210- for every HTTP request.
202+ because the session data will most likely be handled randomly
203+ on a different instance for every HTTP request.
211204
0 commit comments