Home > php教程 > PHP开发 > body text

Session state control in PHP (1).

黄舟
Release: 2016-12-20 11:15:38
Original
1380 people have browsed it

What is session state control? To put it simply, it is cookie and session parameter passing. Today I will talk about the usage of these two methods. As mentioned earlier, the very important page value is passed. Generally speaking, we hope that users who visit a website have a unique identifier. For example, the current member login and member operation functions are implemented using this unique identifier, which improves the efficiency of the website. security and make the website functionally interactive for users better.

Cookie

Cookie is a piece of information sent by the server to the client. It is stored in the memory or hard disk of the client's browser and is mainly used to store user-related information. It is done through the $_COOKIE array.

Using cookies can be divided into three steps:

1. Set Cookie: It can be set using the setcookie() or setrawcookie() function. It can also be set by sending http headers to the client through header().

2. Read cookies: directly use the PHP predefined variable $_COOKIE array, specify the cookie name as the array element index, and you can read the cookies on the browser side.

3. Delete Cookie: Just set the validity time to be less than the current time, set the value to empty, and you can delete it.

However, cookies have the following limitations:

1. They must be set before the content of the HTML file is output;

2. Different browsers handle cookies inconsistently, and sometimes incorrect results may occur. Between different core browsers Cookies cannot be shared.

3. The limit is on the client side. The maximum number of cookies that can be created by a browser is 30, and each cookie cannot exceed 4kb. The total number of cookies that can be set by each website cannot exceed 20.

I will talk about session next time.

The above is the content of session state control in PHP (1). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!