O & M-what happens when PHP uses memcached to save the session?

Source: Internet
Author: User
This is an accidental loss. for example, the $ _ session I read in 2nd ajax requests is an empty array, and the $ _ SESSION value is normal for 3rd requests, however, when I initiate five or six requests at the same time on a page, it is very likely that a session will be lost. how can I solve this problem... this is an accidental loss. for example, the $ _ session I read in 2nd ajax requests is an empty array, and the $ _ SESSION value is normal for 3rd requests, however, when I initiate five or six requests at the same time on a page, it is very likely that a session will be lost. how can I solve this problem?

Php. ini:

session.save_handler = memcachedsession.save_path = "127.0.0.1:11211"

The runtime environment is in my vagrant virtual machine. php and memcahe are all installed in this virtual machine, php is 5.6, and memcache is 1.4.4 ,. The strange thing is that when I use files to store sessions, I have never encountered session loss problems.

Reply content:

This is an accidental loss. for example, the $ _ session I read in 2nd ajax requests is an empty array, and the $ _ SESSION value is normal for 3rd requests, however, when I initiate five or six requests at the same time on a page, it is very likely that a session will be lost. how can I solve this problem?

Php. ini:

session.save_handler = memcachedsession.save_path = "127.0.0.1:11211"

The runtime environment is in my vagrant virtual machine. php and memcahe are all installed in this virtual machine, php is 5.6, and memcache is 1.4.4 ,. The strange thing is that when I use files to store sessions, I have never encountered session loss problems.

The memcache hit rate cannot be so low. Is it because memcache is full? Or are multiple machines used in the background, and the memcache used for session storage is not shared?
The specific problem depends on the code.

The session has a concurrency consistency problem. you can lock the data when writing and release the lock after writing.
See here for an explanation: http://justcoding.iteye.com/B...

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.