Phpredis-php uses redis as the session storage tool

Source: Internet
Author: User
When php uses redis as the session storage tool, when a session is cleared, the user cannot log on. How can I solve this problem? I use two methods to define the session storage mechanism: {code ...} another is {code ...} php5.3.28 and 5.5.10 cannot be... when php uses redis as the session storage tool, users cannot log on to the server due to session cleaning issues.
How can this problem be solved?

I use two methods to define the session storage mechanism
One is

phpini_set('session.save_handler','Redis');ini_set('session.save_path','tcp://localhost:6379');

The other is

session.save_handler = Redissession.save_path = "tcp://localhost:6379"

The session cannot be used normally under php5.3.28 or 5.5.10.
But none of them can be used. How can you solve this problem?
Ps
@ Woshicixide: I wrote all the steps in detail.

First, enable the redis script.redis-server.exe redis.confCommand to run the redis Server
In php. ini, modify session. save_handler to redis.session.save_handler = Redis
In php. ini, modify session. save_path to "tcp: // localhost: 6379"session.save_path = "tcp://localhost:6379"
Restart the Apache service and reload php. ini.
Open the login page http: // localhost/login. php and enter the username and password to log on.
The browser automatically jumps to the logon success page and then returns to the logon page.
Ps writes the login userid to the session in loginaction. php to determine whether to log on.

Reply content:

When php uses redis as the session storage tool, users cannot log on to the server due to session cleaning issues.
How can this problem be solved?

I use two methods to define the session storage mechanism
One is

phpini_set('session.save_handler','Redis');ini_set('session.save_path','tcp://localhost:6379');

The other is

session.save_handler = Redissession.save_path = "tcp://localhost:6379"

The session cannot be used normally under php5.3.28 or 5.5.10.
But none of them can be used. How can you solve this problem?
Ps
@ Woshicixide: I wrote all the steps in detail.

First, enable the redis script.redis-server.exe redis.confCommand to run the redis Server
In php. ini, modify session. save_handler to redis.session.save_handler = Redis
In php. ini, modify session. save_path to "tcp: // localhost: 6379"session.save_path = "tcp://localhost:6379"
Restart the Apache service and reload php. ini.
Open the login page http: // localhost/login. php and enter the username and password to log on.
The browser automatically jumps to the logon success page and then returns to the logon page.
Ps writes the login userid to the session in loginaction. php to determine whether to log on.

I think there is something wrong with your configuration. I will paste my configuration.
[Session]
; Handler used to store/retrieve data.
Http://php.net/session.save-handler
Session. save_handler = redis
Session. save_path = "tcp: // xx. xx: 6789? Persistent = 1 & timeout = 3 & database = 11 & auth = d9cxa2xx67f2xxxxxxxxxx58exx5xfxd29"
I don't know if your redis is up or whether your web server is up or not. Is there any exception. What about redis expansion?

The landlord's question is too big, as if the user is asking why my website cannot be opened. The landlord should at least write such things as what errors are prompted and how you call them.
Check whether your apsaradb for redis requires the account and password, and then change the localhost in the php configuration to 127.0.0.1.

In fact, I prefer to use memcahced to store session data!
The reason is as follows:
1. No Password required
2. Simple data structure and fast response
3. distributed processing is very convenient. One machine is dedicated to session sharing.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.