Learning points:
1. Cookie Application
2. Session Processing
HTTP (Hypertext Transfer Protocol) defines the transmission of text, graphics, video and all
All other data rules. HTTP is a stateless protocol, indicating that each request is processed with the previous or subsequent
The request is independent. Although this simplification has made outstanding contributions to the popularization of HTTP
For Web application developers, this is a bit of a problem. To solve this problem
A small amount of information (cookies) is stored on the machine ).
Due to cookie size restrictions, quantity, and other reasons, developers propose another solution: session
Processing.
1. Cookie Application
Set cookie:Setcookie() Function can generate a cookie file on the client, which can be saved
Time, name, value, and so on.
Create cookie
<?('name','Lee',()+(7*24*60*60?>
Parameter 1: cookie name
Parameter 2: cookie value
Parameter 3: cookie expiration time
Read cookie
<? ['name'?>
Delete cookie
<?('name',''('name','Lee',()-1?>
Cookie usage restrictions
1. It must be set before HTML file content output;
2. Different browsers may encounter inconsistent processing of cookies and sometimes incorrect results.
3. restrictions are imposed on the client. A browser can create up to 30 cookies, and each Cookie cannot
More than 4 kb, each WEB site can set a total of 20 cookies.
Ii. Session Processing
When session processing is used, you must start the session and start the session with session_start.
Create a session and read the session
<?['name'] = 'Lee' ['name'?>
Determine whether a session exists
<?['name'] = 'Lee' ((['name' ['name'?>
Delete session
<?['name'] = 'Lee'(['name' ['name'?>
Destroy all sessions
<?['name'] = 'Lee'['name2'] = 'Lee' ['name' ['name2'?>
Note: This article is a video tutorial from Li Yanhui PHP. This article is intended for communication purposes only and cannot be used for commercial purposes. Otherwise, the consequences will be borne by you.