Session and Cookie differences, how many Web servers share session, disable cookies after the session is available, why?

Source: Internet
Author: User

Answer: Session operation mechanism:

User A accesses Site y, if site y specifies session_start ();(The following Assumption Session_Start () is always present) then a session_id is generated, and this session_ The ID is usually saved to user A in the form of a cookie (we can force the SessionID to be php.ini by setting the Session.use_only_cookies to 1 in the )。 At this time SessionID performance as $_cookie[' Phpsessid '];(P Hpsessid can be modified by Session_name () function)

User A then accesses, and the session ID ($_cookid[' phpsessid ') is routed to site Y each time a accesses Y.

On site Y, there is a directory that is used to hold the actual data of the session. Site Y receives the SessionID, and then passes the session ID, which is associated with the session data and returns the session data.

Answer: The difference between session and Cookie:

Session stored on the server side, users can not be modified, relatively safe, the cookie is stored in the client, the user through means to modify, relatively insecure.

Sessions are saved on the server for a certain amount of time, and when access is increased, server resources are compared.

The limit for a single cookie on the client is 3k, meaning that a site may not store more than 3k of cookies on the client.

Answer: How many servers share the session:

Sharing is a common one for each server, so it's obvious to put this session in one place
such as the database, each server is tuned in the database session
The same principle as memcache

A: Yes, but it is necessary to write the session_id to the URL when the value is passed, because when the parameter is disabled, it will be sent to the back of the URL in the form of parameters!

Session and Cookie differences, how many Web servers share session, disable cookies after the session is available, why?

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.