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 所提供的完整资讯。使用范例 [email protected] (27-May-1999) 所提供的 setcookie() 及 header() 范例。<?php
$status = 0;
if (isset($myTstCky) && ($myTstCky == "ChocChip")) $status = 1;
if (!isset($CCHK)) {
  setcookie("myTstCky", "ChocChip");
  header("Location: $PHP_SELF?CCHK=1");
  exit;
}
?>
<html>
<head><title>Cookie Check</title></head>
<body bgcolor="#FFFFFF" text="#000000">
Cookie Check Status: 
<?php 
printf ('<font color="#%s">%s</font><br>;', 
  $status ? "00FF00" : "FF0000",
  $status ? "PASSED!" : "FAILED!"); 
?>
</body>
</html>

解决方案 »

  1.   

    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 所提供的完整资讯。使用范例 [email protected] (27-May-1999) 所提供的 setcookie() 及 header() 范例。<?php
    $status = 0;
    if (isset($myTstCky) && ($myTstCky == "ChocChip")) $status = 1;
    if (!isset($CCHK)) {
      setcookie("myTstCky", "ChocChip");
      header("Location: $PHP_SELF?CCHK=1");
      exit;
    }
    ?>
    <html>
    <head><title>Cookie Check</title></head>
    <body bgcolor="#FFFFFF" text="#000000">
    Cookie Check Status: 
    <?php 
    printf ('<font color="#%s">%s</font><br>;', 
      $status ? "00FF00" : "FF0000",
      $status ? "PASSED!" : "FAILED!"); 
    ?>
    </body>
    </html>
      

  2.   

    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 所提供的完整资讯。使用范例 [email protected] (27-May-1999) 所提供的 setcookie() 及 header() 范例。<?php
    $status = 0;
    if (isset($myTstCky) && ($myTstCky == "ChocChip")) $status = 1;
    if (!isset($CCHK)) {
      setcookie("myTstCky", "ChocChip");
      header("Location: $PHP_SELF?CCHK=1");
      exit;
    }
    ?>
    <html>
    <head><title>Cookie Check</title></head>
    <body bgcolor="#FFFFFF" text="#000000">
    Cookie Check Status: 
    <?php 
    printf ('<font color="#%s">%s</font><br>;', 
      $status ? "00FF00" : "FF0000",
      $status ? "PASSED!" : "FAILED!"); 
    ?>
    </body>
    </html>
      

  3.   

    setcookie();是设置cookie函数,里边有参数,你可以设置参数。setcookie()是在客户端执行的函数。它在你的机子里边cookies目录里加了一个文件。如果你下次打开这个网页,就可以调setcookie()设置的值。
    最简单的例子:
    1。你这是第**次访问本网站
    2。有的时候你登录网站,提示你保存密码吗?如果保存的话就是把你的帐号和密码存在你的机子里边