As soon as you use the function "setcookie" ,you must use "header" together! Now i will give you some example.
the first file : exam2.php
<?
$coo[0]="00";
$coo[1]="11";;
$coo[2]=1;
setcookie("myname","$coo[0]");
setcookie("myname1","$coo[1]");
setcookie("myname2",$coo[2]);
header("location:exam1.php");
?>
the second file : exam1.php
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<?
echo $myname."****";
echo $myname1."****";
echo $myname2;
?>
<form method="POST" action="exam3.php">
<p>the password<input type="checkbox" name="aa" value="ON"></p>
<p><input type="submit" value="sign" name="B1"><input type="reset" value="restart" name="B2"></p>
<span style="font-size: 9pt">
<input checked name="userkinds" type="radio" value="aaa">
aaa
<input name="userkinds" type="radio" value="aaa">
aaa</span>
</form>
</body>
the third file is exam3.php
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<?
echo $myname;
echo $myname1;
echo $myname2;
?>
<p><a href="exam4.php">aaa</a></p>
</body>
the forth file : exam4.php
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<?
echo "*********".$myname;
echo $myname1;
echo $myname2;
?>
</body>
now you can see the cookie.But you must notice this : when you use cookie,like setcookie("myname","$coo[0]") in exam2, you must use "" to embrace $coo[0].it like & in c.
hilma wrote:
I have created 'userid' and 'password' as cookies on my login.php page, but when I tried to get $userid on the next pake it said it's as unknown variable.
can you help me please. thanks