What does Session mean in PHP?

Guanhui
Release: 2023-03-01 17:26:01
Original
4423 people have browsed it

In PHP, Session is a server-side mechanism that is used to record user-related information so that the user can initiate requests to the Web server again in this capacity. The biggest difference between Session and Cookie is that the latter is Stored on the client side, while the former is stored on the server side.

What does Session mean in PHP?

#Session occupies a very important position in Web technology. Since the web page is a stateless connection program and cannot record the user's browsing status, it is necessary to record the user's relevant information through the Session so that the user can initiate a request to the Web server in this capacity again.

Recommended related articles:The most complete collection of js interview questions in 2020 (latest)

Session means "session" in Chinese. It is similar to Cookie and is used to store user-related information, such as user name, access permissions, login time, etc. The biggest difference with Cookie is that Cookie stores data on the client computer, while Session stores data on the server system.

When a Session is opened, PHP will create a random Session ID (such as "t5is1r7ct740dn390kuv3mpcse"). Each user's Session ID is unique, and the Session ID is the same as the user's Session data stored on the server. The text files have the same name.

Session ID will be saved in two locations: client and server.

  • On the client side, use temporary cookies to save in the directory specified by the browser. The cookie name defaults to "PHPSESSID";

  • On the server side, Save it as a text file in the specified Session directory.

By default, this Session ID will be sent to the web browser as a Cookie, and then the PHP page will use this Cookie to access Session information.

Compared with Cookie, Session has the following advantages:

  • Generally, Session is more secure because the data in Session does not go back and forth between the client and the server. Repeated delivery;

  • Session can store more information than Cookie;

  • When the user disables Cookies, some methods can still be used Can keep the Session working normally.

How Session works

What does Session mean in PHP?

##Recommended Tutorial: "

PHP"

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template