1. What is called session control
Allows the server to make successive requests based on the client.
2. Why do I need session control?
Because when you open a website and want to visit other pages of the site, if there is no session control, when you jump to another page, you need to enter the account and password again.
The principle and function of 3.Cookie
Save the client's simple information on the personal PC, and other programs get the cookie from the PC to get the user's information. This will not require the user to enter their own account and password.
Note: Setcookie () must be used before the first sentence of PHP output, otherwise invalid
4. How to use Cooike (general)
Create a cookie
Setcookie ("Key", "value", retaintime); // Create a cookie
Invoke Cookie
if ($_cookie["key"] = = "Admin"//cookie is a super array provided by PHP echo "Get data Success"; }
Delete Cookies
// The first of these methods Setcookie ("Key"); // just enter the key name///second method Setcookie ("Key", "",Time ()-1000); // make the retention time less than the current time
Cookie support becomes multidimensional array
Setcookie // equivalent to $_cookie["user" ["Key"]
Simple example: cookie-based user login
The principle and function of 5.Session
Store information on a server instead of on a personal PC.
6. How to use the session
(1). Configure the php.ini option (do not expand, query related documents yourself)
(2). Start session
Session_Start (); // The method must be called before the session can be used
Role: Pre-load the built-in environment variables associated with the session into memory.
(3) Call
$_session ["key"] = "value"; // $_session is also a super array and is called as an array
(4) Delete
// Single Delete unset ($_session["Key"]); // Delete all $_session Array // set to an empty array//the user on the server side of the session file to delete session_destory ();
The above describes the php--session control, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.