PHP session handler

Runs in a web application on two or more servers, need to take into account the session sharing problem, otherwise there will be landing exception. session is the most common way to store files in the / tmp directory, write your local disk is slow, there are two problems: 1. In the case of high concurrency or session expired a long time, it will generate a lot of files, find files result in a slow, the number of files created in each directory is limited, it could lead to a new session store failed. 2. When session_start, will lock a file until the end of program execution after release the lock, block other concurrent programs session_start. The second way is stored in a relational database such as mysql database, which in the case of high concurrency, lock table is very serious, affecting performance. Another is a key-value database to store, such as memcached, most of the site is to use memcached to store session data. You can also use redis do storage. memcached and redis comparison is not presented here, we are interested, there are introduced under this blog, you can search. redis session storage implementations do the following: First of all extensions have to install redis PHP. Next you need to edit your php.ini file, modify the contents:
extension=redis.so

session.save_handler = redis
session.save_path = "tcp://localhost:6379/"
Restart php-fpm to take effect. For reprint please indicate the source: http: //www.ttlsa.com/html/3516.html

Reproduced in: https: //my.oschina.net/766/blog/211492

Guess you like

Origin blog.csdn.net/weixin_33690963/article/details/91493023