Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a39cae

Browse files
tuxmartinmichael-grunder
authored andcommitted
add: session.save_path examples
1 parent 3dbc2bd commit 8a39cae

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ see the [INSTALL.md](./INSTALL.md) page.
6565

6666
## PHP Session handler
6767

68-
phpredis can be used to store PHP sessions. To do this, configure `session.save_handler` and `session.save_path` in your php.ini to tell phpredis where to store the sessions:
69-
~~~
70-
session.save_handler = redis
71-
session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2&read_timeout=2.5"
72-
~~~
68+
phpredis can be used to store PHP sessions. To do this, configure `session.save_handler` and `session.save_path` in your php.ini to tell phpredis where to store the sessions.
7369

7470
`session.save_path` can have a simple `host:port` format too, but you need to provide the `tcp://` scheme if you want to use the parameters. The following parameters are available:
7571

@@ -84,6 +80,26 @@ Sessions have a lifetime expressed in seconds and stored in the INI variable "se
8480
The session handler requires a version of Redis supporting `EX` and `NX` options of `SET` command (at least 2.6.12).
8581
phpredis can also connect to a unix domain socket: `session.save_path = "unix:///var/run/redis/redis.sock?persistent=1&weight=1&database=0"`.
8682

83+
### Examples
84+
85+
Multiple Redis servers:
86+
~~~
87+
session.save_handler = redis
88+
session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2&read_timeout=2.5"
89+
~~~
90+
91+
Login to Redis using username and password:
92+
~~~
93+
session.save_handler = redis
94+
session.save_path = "tcp://127.0.0.1:6379?auth[]=user&auth[]=password"
95+
~~~
96+
97+
Login to Redis using username, password, and set prefix:
98+
~~~
99+
session.save_handler = redis
100+
session.save_path = "tcp://127.0.0.1:6379?auth[]=user&auth[]=password&prefix=user_PHPREDIS_SESSION:"
101+
~~~
102+
87103
### Session locking
88104

89105
**Support**: Locking feature is currently only supported for Redis setup with single master instance (e.g. classic master/slave Sentinel environment).

0 commit comments

Comments
 (0)