About IE session loss related issues. Ask the gods to help.

Source: Internet
Author: User
About IE's session loss problem: For the help of the great Gods of the road
The code is simple.

Session_Start ();
Header ("Content-type:text/html;charset=utf-8");
Setcookie (' username ', "AA", Time () +3600*24*365);

echo "PHPSESSID:". $_cookie[' Phpsessid ');


In the firefox,chrome can display the PHPSESSID normally, but in IE has written session, but cannot write to $_cookie[' PHPSESSID '], resulting in the subsequent tune not to the session content. Ask for answers
Environmental IE6

Share to: more


------Solution--------------------
Just refresh it, unless you close the cookie.
------Solution--------------------
Setcookie (' username ', "AA", Time () +3600*24*365, "/");
------Solution--------------------
See the landlord Session_Start immediately after Echo Phpsessid.
Setcookie Although the server will send cookie data to the browser, but the $_cookie array will not immediately get this corresponding key, including the first session_start after the cookie will not be immediately phpsessid, The creation of the cookie array is when the request occurs, the browser comes with a cookie to the server, the server is generated, not the Setcookie changes in real time

So the first time the Setcookie or Session_start,$_cookie array is empty, but the client has already had cookie data, and so on when the client refreshes and requests it, there will be the contents of the cookie array. But landlord refresh more than a few times will not see the error. I hope the landlord has a correct understanding of this aspect, or perhaps you already know.
==========================================


The point, according to my experience, to send a cookie to be compatible with IE browser, you must take the path parameter in the parameters of the Setcookie function
  • 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.