Cross-Server session solution in php

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff to enter the php session cross-Origin Cross-server solution: Check it online, except asp.net, all sessions must be retained with sessionid. The storage location of the Session is as follows: shared files, databases, and memcache. The main problem is

Welcome to the Linux community forum and interact with 2 million technical staff> go to the php session cross-Origin Cross-server solution: Check it online, except for asp.net, the session id must be used to retain all sessions. The storage location of the Session is as follows: shared files, databases, and memcache. The main problem is

Welcome to the Linux community forum and interact with 2 million technicians>

In php, the cross-Origin Cross-Server Solution of session: After checking on the Internet, except asp.net, all session retention must use the session id. The storage location of the Session is as follows: shared files, databases, and memcache. Therefore, the main problems are the transfer of session IDs.

The Session id is transmitted in four ways:

1. Use cookies.

2. Set session. use_trans_sid = 1 in php. ini or enable the -- enable-trans-sid option when compiling, so that PHP can automatically pass the session id across pages.

3. Manually pass values through URLs or hide forms.

4. It is transmitted as a file or database, and the value is corresponding to another key.

The above two and three actually use the same method, but the approach is different.

Through the above analysis, we can easily see that passing session IDs through cookies and storing sessions on the memcache Server is a reasonable choice. When cross-origin occurs, you can use p3p to set cookie cross-origin. When the client disables the cookie, you can set php. ini to automatically pass the session id through the url.

The following uses pass as an example to describe the logic implementation process (depending on the requirements, If You Want To ensure interface consistency and shield the session server from other servers, all login and session information can be transferred through the login server, but this will naturally lead to time delays and the risk of Full-site paralysis caused by server downtime ):

Including services and applications: log on to the server, save the memcache server for the session, the application server, the public key, and the key

(1) For trusted servers:

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.