Questions about the PHP session changing every time it is refreshed

Source: Internet
Author: User

Questions about the PHP session changing every time it is refreshed

This morning found that the session saved problems, can not pass the session. Read PHP files are not any exception, and no error.

Found on the Internet some articles, said whether the php.ini file inside the Session.save_path is not set up, and then looked at, and did not find any problem, the path is right. Find the directory to save the session file, found that each refresh will generate a new session file, and then try to print session_id () , if so, each refresh will update session_id ().

Then continue to look for more information on the network, some people say it is a cookie problem, because session_id is also carried through the cookie, I try to use the command to print out the value of the cookie var_dump ($_cookie), Finding that the returned value is Array (0) {} does not have anything, which proves that there is a problem with the cookie.

Follow the whole idea to find, and finally found that the session before the cross-domain change the php.ini inside the session.cookie_domain settings, as follows

Session.cookie_domain = ". Zssd.mobi"

Here is the setting of cookies can only be in the top-level domain name Zssd.mobi, the purpose is to solve cross-domain problems, but other domain names have problems (about multiple domain names to implement the session cross-domain may need to use other methods to solve), as long as the Session.cookie_ Domain set to empty will be able to use sesssion_id, the specific changes are as follows

Session.cookie_domain =

Then restart Apache, problem solved.

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