Differences between Cookie and Session _ PHP Tutorial

Source: Internet
Author: User
Cookie and Session. Http is a stateless connection. to track user behavior, there must be a variable that works different from the page, cookie and session can be used in PHP. The co http protocol is a stateless connection. to track user behavior, there must be a variable that works different from the page, cookie and session can be used in PHP.
Cookie is familiar to everyone, that is, saving the variable as a file on the client. However, if the customer disables the cookie, there is no way. This requires the session. in PHP4, the session can be implemented in two ways. one is to use cookies, that is, to save the sessionID in the cookie file; the second is to attach sessionID to the URL for transmission.
Although these two methods are implemented, PHP automatically checks the client's cookie settings (linux/unix platform, Win32 unknown) as to which method is used without the worry of programmers ), by default, cookies are used preferentially (you can modify php. session in the [session] section of the INI file. use_cookies ). You can also use a URL to transmit the SessionID as follows:
"> Submit a form
Add only one sentence in the link That's all, right? In php. ini also has many Session settings, such as session. cookie_lifetime is the effective time of the session. it is all in the [session] section. if you look at it, you will have a better understanding of the session in PHP.

Bytes. Co...

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.