Store a user's information, change the user session settings, all pages can be used. This article is mainly to share with you the PHP development session principle and the use of detailed, hope to help everyone.
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 ();? >
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 ();?