给你抄了一点资料, 来自PHP手册:
PHP scripts often generate dynamic content that must not be cached by the client browser or any proxy caches between the server and the client browser. Many proxies and clients can be forced to disable caching with 
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 
                                                     // always modified
header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");                          // HTTP/1.0
 
注: You may find that your pages aren't cached even if you don't output all of the headers above. There are a number of options that users may be able to set for their browser that change its default caching behavior. By sending the headers above, you should override any settings that may otherwise cause the output of your script to be cached. Additionally, session_cache_limiter() and the session.cache_limiter configuration setting can be used to automatically generate the correct caching-related headers when sessions are being used. 

解决方案 »

  1.   

    cookie的内容在浏览器向服务器发出http请求时,就同时传递到服务器了。在响应请求的代码中设置的cookie要到下一次受到请求是才能得到
      

  2.   

    http://fxstudio.51.net/others/36goodphp.htm
      

  3.   

    <?
    if ($action) {
       SetCookie("cookie".$name, $value, 0, "/", ".beiji.com");
       echo "<P>Setting Cookie: $name to $value<BR>\n";
       echo "(reload this form to see if this value is reported)\n";}?>
    <HTML><HEAD>
    <TITLE>cookie test</TITLE>
    </HEAD>
    <BODY>
    <H2>cookie test</H2>
    <?
    echo "<P>Reporting your cookies:<BR>\n";
    while (list($key, $value) = each($GLOBALS)) {
       if (ereg('cookie',$key)) {
          echo "$key: $value<BR>\n";
       }
    }
    ?>
    <HR NOSHADE>
    <H3> Set some cookie values: </H3>
    <FORM METHOD="POST" ACTION="<?echo $PHP_SELF;?>">
    <TABLE BORDER=1>
    <TR><TH>Name:
        <TD><INPUT NAME="name" size=8 MAXLENGTH=8>
        <TH>Value:
        <TD><INPUT NAME="value" size=30 MAXLENGTH=30>
    <TR><TH>Action:
        <TD><INPUT TYPE="SUBMIT" NAME="action" VALUE="Submit">
        <TD><INPUT TYPE=RESET VALUE="Clear Form">
    </TABLE>
    </FORM>
    </BODY>
    </HTML>
      

  4.   

    setcookie
    送出 Cookie 信息到浏览器。
    语法: int setcookie(string name, string value, int expire, string path, string domain, int secure);
    返回值: 整数
    函数种类: 网络系统
    内容说明 
    本函数会跟着标头 Header 送出一段小信息字符串到浏览器。使用本函数要在送出 HTML 资料前,实际上 cookie 也算标头的一部份。本函数的参数除了第一个 name 之外,都是可以省略的。
    参数 name 表示 cookie 的名称;
    value 表示这个 cookie 的值,这个参数为空字符串则表示取消浏览器中该 cookie 的资料;
    ************* expire 表示该 cookie 的有效时间;********************
    path 为该 cookie 的相关路径;
    domain 表示 cookie 的网站;
    secure 则需在 https 的安全传输时才有效。想得到更多的 cookie 信息可以到 http://www.netscape.com/newsref/std/cookie_spec.html,由 cookie 原创者 Netscape 所提供的完整信息。