[PHP Learning log] Simple session of the use of PHP learning log session
First of all, give some explanation of the session: the most practical network protocol is the HTTP Hypertext Transfer Protocol, it is "stateless", so-called "stateless" refers to it when the user interacts with the server does not store the need to interact with the "state." The session is the "Conversation control" module in the network application. Therefore, the session object stores the information required for a specific user session, which is the "status" information mentioned earlier. Thus, when a user jumps between the application's Web pages, the variables stored in the session object will not be lost, but persist throughout the user's session to achieve the user's interaction with the server.
Here I am learning how to use the session of PHP, so first put a piece of code:
1 php 2 session_start(); 3 //... code 4 ?>
This opens the session directly, calling this method, the server will recognize if there is already a session already in use, if it exists it will call the session directly, if it does not exist, the server will reopen a session, and assign it a unique ID. And is the reliability of a session guaranteed? (that is, in different PHP pages, we need to open the same session) the answer is yes, the system will again use the same ID session each time the "session_start ()" method is called. Then I'll post a piece of code:
1
PHP2 session_id(ID); 3 Session_Start (); 4 // ... code 5 ?>
As you can see, the difference between this code and the previous paragraph is that the call to the "session_id ()" method is added. Here's an explanation: the "session_id ()" Method has two functions:
- Open session with specified ID
- Gets the ID of the session that is currently open
So here we are obviously by specifying a id=id to open this session, the advantage is that the session is more stable call. (It is not recommended to do this directly, you can use a cookie to store the session ID to achieve a stable reply)
http://www.bkjia.com/PHPjc/1119063.html www.bkjia.com true http://www.bkjia.com/PHPjc/1119063.html techarticle [PHP Learning log] Simple session of the use of PHP learning log session First, give some explanation of the session: the most practical network protocol is the HTTP Hypertext Transfer Protocol, it is stateless ...