This article is mainly for you to share a PHP introductory session of the method, with a good reference value, I hope to be helpful to everyone. Follow the small series together to see it.
Function: Store a user's information, change the user session settings, all pages can be used.
PHP Session variables
Open the program, make some changes, and then save the exit. is a session. The server can know who is operating through the session.
Working mechanism: Create a UID for the visitor, depending on the UID store variable, the UID is stored in a cookie, or URL conduction.
Using the PHP Session
Store user information before session, initiate a reply
Note: the Session_Start () function must precede the label:
<?php session_start (); ? >
Register user sessions with the server to save user information while assigning a UID to a user session
Store Session variables
Storing and retrieving sessions is used$_SESSION
<?phpsession_start ()///Store session data if (Isset ($_session[' views '))} { $_session[' views ']=$_session[' views ']+ 1;} else{ $_session[' views ']=9999;}? >
Output "Views: 9999"
Destroy Session
Which or function to use to unset() session_destroy() destroy
<?phpsession_start (); if (Isset ($_session[' views ')) { //releases the specified SESSION variable unset ($_session[' views ');} Complete destruction of Sessionsession_destroy ();? >
Related recommendations:
Session Principle and realization sharing
Session principle
How the session works in PHP