Store a user's information, change the user session settings, and all pages can be used. This article mainly shares with you the principles of PHP Session development and detailed usage instructions. I hope it can help you.
Open the program, make some changes, then save and exit. It's just a session. The server can know who is operating through the session.
Working mechanism: Create a uid for the visitor, store variables according to this uid, the uid is stored in a cookie, or URL transmission.
Related topic recommendations: php session (including pictures, texts, videos, cases)
Start the session before storing user information in the session
Note: The session_start() function must be located before the <html>
tag:
1 2 3 |
|
Register the user session with the server , convenient for saving user information, and assigning a uid to the user session
To store and obtain session, use $_SESSION
1 2 3 4 |
|
Output "Views: 9999"
Which unset()
or session_destroy()
function is used to destroy
1 2 3 4 |
|
Function: Store a user's information, change user session settings, and can be used on all pages.
Open the program, make some changes, then save and exit. It's just a session. The server can know who is operating through the session.
Working mechanism: Create a uid for the visitor, store variables according to this uid, the uid is stored in a cookie, or URL transmission.
Save user information before the session and start the session
Note: The session_start() function must be located before the <html>
tag:
1 2 3 |
|
Register the user session with the server to facilitate saving user information, and assign a uid to the user session
Store and obtain session using $ _SESSION
1 2 3 4 |
|
Output "Views: 9999"
Which one to useunset()
or session_destroy()
Function destruction
1 2 3 4 |
|
Related recommendations:
PHP Session principle analysis and use
Analysis of SESSION principle in PHP and large websites Application Notes
Session Principle Brief Description_PHP Tutorial
The above is the detailed content of PHP Session Development Principles and Detailed Usage. For more information, please follow other related articles on the PHP Chinese website!