Questions about cookies and session in PHP

Source: Internet
Author: User
Preamble: The relationship between the client cookie and the service-side session is somewhat blurred, and the session designation cannot be used after the cookie is disabled, and it is verified that the error is not found.

1: Setting values for session in PHP environment php.ini:

Processing session access Mode Session.save_handler = files//session file storage path Session.save_path =/tm P//session using the function of cookies, start: 1 session.use_cookies = 1//session name Session.name        = PHPSESSID//Auto start, 0: off; 1: On session.auto_start = 0//session The lifetime of the cookie used, in seconds Session.cookie_lifetime = 0 These default values, you can use the session without modification.    2: But when we have a browser to disable cookies, it will appear what you think, the session can not be used. At this point we should study in the php.ini to find out session.use_trans_sid = 1//This field allows SessionID to be transmitted via the URL session.use_only_cookies = 1;    Turn on the use of cookies only to store the session ID at this time again to test the discovery session was acquired. But when session.use_only_cookies = 0; Cannot get to the session, in php.ini this value defaults to 03: code: ① When the browser does not disable cookies: a.php:
 b.php
 ② when the browser disables the cookie and set php.ini Session.use_trans_sid = 1//This field allows SessionID to be transmitted via the URL session.use_only_cookies = 1; Turn on only using cookies to store session ID code: a.php
 b.php
 

The above is my understanding of the cookie and session, if not, can leave a message, study together, progress.

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