详细用法看新版手册
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 所提供的完整信息。 cookie创建在客户端,保存在C:\WINNT\Cookies 里
如果没有过期,echo $_COOKIE['var'];

解决方案 »

  1.   

    例子 1. setcookie() send examplessetcookie ("TestCookie", $value);
    setcookie ("TestCookie", $value,time()+3600);  /* expire in 1 hour */
    setcookie ("TestCookie", $value,time()+3600, "/~rasmus/", ".utoronto.ca", 1);
     
     
    When deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser. Examples follow how to delete cookies sent in previous example: 例子 2. setcookie() delete examples// set the expiration date to one hour ago
    setcookie ("TestCookie", "", time() - 3600);
    setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".utoronto.ca", 1);
     
     
    Note that the value portion of the cookie will automatically be urlencoded when you send the cookie, and when it is received, it is automatically decoded and assigned to a variable by the same name as the cookie name. To see the contents of our test cookie in a script, simply use one of the following examples: 
    echo $TestCookie;
    echo $_COOKIE["TestCookie"];