@@ -76,8 +76,10 @@ First, define a Symfony service for the connection to the Redis server:
76
76
// ->addMethodCall('auth', ['%env(REDIS_PASSWORD)%'])
77
77
;
78
78
79
- Now pass this Redis connection as an argument of the service associated to the
80
- :class: `Symfony\C omponent\H ttpFoundation\S ession\S torage\H andler\R edisSessionHandler `:
79
+ Now pass this ``\Redis `` connection as an argument of the service associated to the
80
+ :class: `Symfony\C omponent\H ttpFoundation\S ession\S torage\H andler\R edisSessionHandler `.
81
+ This argument can also be a ``\RedisArray ``, ``\RedisCluster ``, ``\Predis\Client ``,
82
+ and ``RedisProxy ``:
81
83
82
84
.. configuration-block ::
83
85
@@ -155,7 +157,16 @@ configuration option to tell Symfony to use this service as the session handler:
155
157
],
156
158
]);
157
159
158
- That's all! Symfony will now use your Redis server to read and write the session data.
160
+ That's all! Symfony will now use your Redis server to read and write the session
161
+ data. The main drawback of this solution is that Redis does not perform session
162
+ locking, so you can face *race conditions * when accessing sessions. For example,
163
+ you may see an *"Invalid CSRF token" * error because two requests were made in
164
+ parallel and only the first one stored the CSRF token in the session.
165
+
166
+ .. seealso ::
167
+
168
+ If you use Memcached instead of Redis, follow a similar approach but replace
169
+ ``RedisSessionHandler `` by :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ MemcachedSessionHandler `.
159
170
160
171
Store Sessions in a Relational Database (MySQL, PostgreSQL)
161
172
-----------------------------------------------------------
0 commit comments