[PHP Learning log] Simple session of the use of PHP learning log session_php Tutorial

Source: Internet
Author: User

[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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.