What is the Session in php?

Source: Internet
Author: User
Compared with the Cookie, the data stored in the Session file is created as a variable in the PHP script. the created Session variable is in the lifecycle (20 minutes) can be referenced by cross-page requests. Compared with the Cookie, the data stored in the Session file is created as a variable in the PHP script. the created Session variable is in the lifecycle (20 minutes) can be referenced by cross-page requests. In addition, Session is stored on the server, which is relatively secure and does not have the storage length limit as the Cookie does. In a Web system, it usually refers to the dialog process between a user and a Web system. That is, from the time when the user opens the browser and logs on to the Web system, and closes the browser and leaves the Web system, the variables that the same user registers in the Session, this user can use each Web page during painting, and each user can use its own variables.

1. what is Session?

Session refers to a series of actions/messages that start and end, such as the process from picking up the phone to dialing to hanging up the phone when making a call.

In computer terminology, Session refers to the time interval between an end user and an interactive system for communication. it usually refers to the time from registration to entry into the system to logout from the system. Therefore, Session is actually a specific concept of time.

2. how the Session works

When a Session is started, a random and unique Session_id is generated, that is, the Session file name. at this time, Session_id is stored in the memory of the server. When the page is closed, this id is automatically deregistered. if you log on to the page again, a random and unique id is generated again.

3. Session functions

Session is very important in Web technology. Desire is also a stateless Connection program, so you cannot know the user's browsing status. Through Session, you can record the user's related information for the user to confirm the Web server's submission requirements in this identity. For example, on an e-commerce website, a Session is used to record user login information and the purchased items. If no Session exists, you need to log on to the user name and password every time you enter a page.

In addition, Session is suitable for storing a small amount of information. If you need to store a small amount of information and do not need to store the stored content for a long time, it is appropriate to use Session to store the information on the server.

The above is the details of the Session in php. For more information, see other related articles in the first PHP community!

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.