The difference between a cookie and a session _php tutorial

Source: Internet
Author: User
HTTP protocol is a stateless connection, in order to track the behavior of users must have a can work on different from the page variables, in PHP can be used in the cookie and session two ways to achieve.
Cookie is more familiar, is to save the variable as a file on the client side, but if the customer forbid the cookie will not be able to. This requires a session, in the PHP4, the session can be implemented in two ways, one is to use a cookie, that is, the sessionid stored in a cookie file, and the second is to carry the SessionID attached to the URL for delivery.
Although there are two ways to do this, but as to which method is not necessary for the programmer to worry about, PHP will automatically check the settings of the customer cookie (referring to the Linux/unix platform, Win32 unknown), and the default is to use the cookie preference (you can modify the php.ini file in the [ Session] section of the Session.use_cookies value to change). Of course you can also force the use of URLs to pass SessionID, as follows:
The > Submit Form
Add only one sentence to the link It's all right, easy? In the php.ini there are many settings about the session, such as Session.cookie_lifetime is the time of the session, and so on, in the [Session] section, if you look at the session in PHP will have more understanding.

http://www.bkjia.com/PHPjc/532091.html www.bkjia.com true http://www.bkjia.com/PHPjc/532091.html techarticle HTTP protocol is a stateless connection, in order to track the behavior of users must have a can work on different from the page variables, in PHP can be used in the cookie and session two ways to achieve. Co ...

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