Sessions get messed up on external host

前端 未结 1 540
你的背包
你的背包 2021-01-27 05:09

The problem sounds like this: The log-in using sessions works perfect on my localhost, but when the EXACTLY same files are uploaded to my host (hostgator), the sessions don\'t o

相关标签:
1条回答
  • 2021-01-27 05:36

    I noticed on Firefox with Firebug that your pages are all cached . Your session is working fine, but your page are cached, making login and logout quite (messed up).

    Disable HTTP caching for your dynamic pages.

    See Firebug output:

    Response Headers

    HTTP/1.1 304 Not Modified
    Date: Thu, 14 Oct 2010 13:16:50 GMT
    Server: Apache mod_fcgid/2.3.5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
    Connection: Keep-Alive
    Keep-Alive: timeout=5, max=100
    Expires: Thu, 14 Oct 2010 16:16:50 GMT
    Cache-Control: public, max-age=10800
    

    Request Headers

    GET / HTTP/1.1
    Host: www.piataterenuri.info
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Cookie: PHPSESSID=55aea3f792334052dc673f85feb0b54a
    If-Modified-Since: Wed, 13 Oct 2010 13:47:53 GMT
    Cache-Control: max-age=0
    

    PHP manual has already an example on how to disable caching:

    http://php.net/manual/en/function.header.php

    <?php
    
    header("Cache-Control: no-cache, must-revalidate"); 
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    
    ?>
    
    0 讨论(0)
提交回复
热议问题