PHP session doesn't work with IE

前端 未结 12 1093
后悔当初
后悔当初 2020-12-09 05:10

I have a site made with php which uses server side sessions throughout the site.
In fact, it\'s a site with a user login which depends on session variables and if there

相关标签:
12条回答
  • 2020-12-09 05:39

    I thought some people might find the solution to this problem interesting. Fiddler certainly helped here. Thanks to Fiddler, I could see that I was, in fact, hitting the page main.php (thus setting the session variable moments after setting it on the target page), but the server was defaulting there after getting a 302 on the root of the site. This was all happening silently in the background, and before my onload="" javascript ran.

    So I was sure something on those pages was causing an error, but not a catastrophic one.

    here it is: <img src= "" >

    IE was freaking out about the blank src attribute and hitting the server root and the defaulting to page main. I don't fully understand the mechanics happening here. I also don't understand if this is how IE is supposed to behave (it is a malformed img tag after all) or not. Is this a bug?

    0 讨论(0)
  • 2020-12-09 05:41

    I have the same problem and it's SOLVED now.

    The blank or empty attribute's values of any IMG tags cause the problem. For me, I used JavaScript to change IMG object's source to an empty value. Doing that could also make the problem.

    0 讨论(0)
  • 2020-12-09 05:43

    I had the same problem with ie7 and this is what I do:

    If you have this problem using a IIS or Apache in Windows Server, look at the URL where you are redirecting it must be writed in the same way as the URL where you was before the redirection.

    For example: site.com/pages/index.php redirection to site.com/Pages/index2.php is going to loose the session in IE7 because the capital letter in Pages.

    0 讨论(0)
  • 2020-12-09 05:48

    In most cases, this php line at file begining will be enough:

    header('P3P: CP=”NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM”');
    

    If it isn't, for IE7 you may also try:

    header('P3P: CP=”NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM”');
    
    header('Set-Cookie: SIDNAME=ronty; path=/; secure');
    
    header('Cache-Control: no-cache');
    
    header('Pragma: no-cache');
    

    And if that doesn't work for IE6, you may use GET params for session ID:

    header('location: land_for_sale.php?phpSESSID='.session_id());
    
    0 讨论(0)
  • 2020-12-09 05:48

    If I understand it correctly, you are trying to use a session variable to pass data from a page to pages within iframes on that page? This doesn't seem a good way to go about it - why not just pass a GET variable into the iframe url i.e. ?current_page=special1 . I would think this would be more reliable as it does not rely on session state.

    Remember also that the session variables will be the same for several pages of the same site that are open on a user's PC (e.g. on multiple tabs), which could cause odd behaviour.

    0 讨论(0)
  • 2020-12-09 05:51

    Check the name of the server machine. IE has problems with machine names that contain '-' or '_' - they cannot maintain a session! I've had this problem twice in the past, and it always takes me weeks to figure out, and I'm shocked IE hasn't fixed it.

    Just rename the machine to have no strange characters! You can get it working if you just use the IP address of the server in the url to test.

    0 讨论(0)
提交回复
热议问题