Home  >  Article  >  Backend Development  >  What is Session in php

What is Session in php

伊谢尔伦
伊谢尔伦Original
2017-04-25 14:03:233792browse

What is Session in php

Compared to Cookie, the data saved in the Session session file is created in the form of variable in the PHP script. The created session Variables can be referenced by cross-page requests within the lifecycle (20 minutes). In addition, the Session is stored on the server side, which is relatively safe and does not have a storage length limit like Cookie. In a Web system, it usually refers to the conversation process between the user and the Web system. That is to say, from the time when the user opens the browser and logs in to the Web system to closing the browser and leaving the Web system, the variables registered by the same user in the Session can be used by the user in each Web page during the painting period. Each user Use your own variables.

1. What is Session

Session is translated as "conversation", and its original meaning refers to a series of actions/messages that have a beginning and an end. For example, when making a phone call, the series of processes from picking up the phone and dialing to hanging up the phone can be called a Session.

In computer terminology, Session refers to the time interval between an end user communicating with an interactive system. It usually refers to the time elapsed from registering to enter the system to logging out of the system. Therefore, Session is actually a specific time concept.

2. Session working principle

When a Session is started, a random and unique Session_id will be generated, which is the Session file name, at this time Session_id is stored in the server's memory. When the page is closed, this ID will automatically log out. When you log in to this page again, a random and unique ID will be generated again.

3. Function of Session

Session is very important in Web technology. Desire is also a stateless connection program, so the user's browsing status cannot be known. Through Session, the user's relevant information can be recorded for users to confirm when submitting requests to the Web server in this capacity. For example, in an e-commerce website, the user's login information and the products purchased by the user are recorded through the Session. If there is no Session, the user needs to log in with a username and password every time he enters a page.

In addition, Session session is suitable for situations where the amount of stored information is relatively small. If the amount of information that the user needs to store is relatively small, and the stored content does not need to be stored for a long time, then it is more appropriate to use Session to store the information on the server side.

Related topic recommendations: php session (including pictures, texts, videos, cases)

The above is the detailed content of What is Session in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn