Unknown software exception The concept of Session in PHP

Source: Internet
Author: User
What is a session? It is difficult to translate the session directly into Chinese, which is usually translated into time domain. In computer terminology, a session is a time interval between an end user communicating with an interactive system, usually the time elapsed between registering and logging out of the system. The specific session in the Web refers to the amount of time that a user has spent browsing a website, from entering the Web site to the browser closing. So from the definition above we can see that the session is actually a specific time concept.
It is important to note that the concept of a session needs to include specific clients, specific server-side, and non-disruptive operating times. A the session where the user and the C server are connected when the connection is established between the B user and the C server is two different sessions in the sessions.
What is the session solution? We know that when users visit a website, they often need to browse many pages. For a website built by PHP, users need to execute a lot of PHP scripts during their visit. However, due to the characteristics of the HTTP protocol itself, each PHP script executed by the user needs to reestablish the connection with the Web server. Because of the characteristics of stateless memory, this connection cannot get the status of the last connection. In this way, the user assigns a variable to a PHP script and cannot get the value of the variable in another PHP script. For example, the user sets the $user= "Wind" in the PHP script responsible for logging in, but cannot get the "wind" value by calling $user in another PHP script. In other words, you cannot set global variables in PHP. The variables defined in each PHP script are local variables that are valid only within the script.
The session solution is to provide a way to define global variables in a PHP script so that the global variable is valid for all PHP scripts in the same session. As we mentioned above, the session is not a simple concept of time, and a session includes a specific user and server. So in more detail, the scope of the global variables defined in a session refers to all of the PHP that the user of the session is accessing.
For example, a user defines a global variable $user= "Wind" through the session, while the B user $user= "Jane" through a global variable defined by the session. So in PHP scripts accessed by a user, the value of $user is wind.

The above describes the unknown software exception PHP in the concept of the session, including the unknown software exception aspect of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.