the cookis it is some info sent and save in user computer
whare i can use the cookies?
becouse the cookies it like the header you can not send it after any output
wes sent so you must send the cookies before any output like as
<html > ,echo and any other code
i well make an E.X. to use the cookies
you must have 2 file
index.php
update.php
----------
in the index.php add this code
CODE
<?
// This section must go at the top of the page that will display
// the users favorites. These are the 'default' URLs that the user
// will see if they have not edited any.
if (strlen ($favorite[1]) < 3) setcookie("favorite[1]", "www.robscripts.com", time()+30000);
if (strlen ($favorite[2]) < 3) setcookie("favorite[2]", "www.digitaledge.com", time()+30000);
if (strlen ($favorite[3]) < 3) setcookie("favorite[3]", "www.penpalseek.com", time()+30000);
if (strlen ($favorite[4]) < 3) setcookie("favorite[4]", "www.budgetideas.com", time()+30000);
if (strlen ($favorite[5]) < 3) setcookie("favorite[5]", "www.cardfan.com", time()+30000);
?>
<html>
<head>
<title>Favorites</title>
</head>
<body>
Current Favorites:
<p>
<!-- Start favorites code: This can be put on any php page, anywhere. -->
<?
for ($x = 1; $x <= 5; print "$x: <a href='http://$favorite[$x]' target='_BLANK'>$favorite[$x]</a><br>", $x++);
?>
<BR><BR>
<a href='update.php'>Update Favorites</a>.
<!-- End favorites code -->
</body>
</html>
// This section must go at the top of the page that will display
// the users favorites. These are the 'default' URLs that the user
// will see if they have not edited any.
if (strlen ($favorite[1]) < 3) setcookie("favorite[1]", "www.robscripts.com", time()+30000);
if (strlen ($favorite[2]) < 3) setcookie("favorite[2]", "www.digitaledge.com", time()+30000);
if (strlen ($favorite[3]) < 3) setcookie("favorite[3]", "www.penpalseek.com", time()+30000);
if (strlen ($favorite[4]) < 3) setcookie("favorite[4]", "www.budgetideas.com", time()+30000);
if (strlen ($favorite[5]) < 3) setcookie("favorite[5]", "www.cardfan.com", time()+30000);
?>
<html>
<head>
<title>Favorites</title>
</head>
<body>
Current Favorites:
<p>
<!-- Start favorites code: This can be put on any php page, anywhere. -->
<?
for ($x = 1; $x <= 5; print "$x: <a href='http://$favorite[$x]' target='_BLANK'>$favorite[$x]</a><br>", $x++);
?>
<BR><BR>
<a href='update.php'>Update Favorites</a>.
<!-- End favorites code -->
</body>
</html>
in the update.php add this code
CODE
<?
// Location of the page where the users links are displayed.
// Example: [url]http://www.yoursite.com/index.php/[/url]
$loc = "http://www.darpac.com/~robert/favorites/";
// How long do you want the users cookies to save their
// favorite links? In seconds. Day=86400 Week=604800
// month=2419200 year=29030500
$exp = 29030500;
if ($state == "update") {
setcookie("favorite[1]", $fav1, time()+$exp);
setcookie("favorite[2]", $fav2, time()+$exp);
setcookie("favorite[3]", $fav3, time()+$exp);
setcookie("favorite[4]", $fav4, time()+$exp);
setcookie("favorite[5]", $fav5, time()+$exp);
$state = "done";
header("Location: $loc");
} else {
if (strlen ($favorite[1]) < 3) setcookie("favorite[1]", "www.robscripts.com", time()+300000);
if (strlen ($favorite[2]) < 3) setcookie("favorite[2]", "www.digitaledge.com", time()+30000);
if (strlen ($favorite[3]) < 3) setcookie("favorite[3]", "www.penpalseek.com", time()+300000);
if (strlen ($favorite[4]) < 3) setcookie("favorite[4]", "www.budgetideas.com", time()+300000);
if (strlen ($favorite[5]) < 3) setcookie("favorite[5]", "www.cardfan.com", time()+300000);
}
?>
<html>
<head>
<title>Favorites</title>
</head>
<body>
Update Favorites:
<form method="POST" action="update.php">
<?
for ($x = 1; $x <= 5; print "$x: <input type='text' name='fav$x' size='29' value='$favorite[$x]'><br>", $x++);
?>
<input type="hidden" value="update" name="state">
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
// Location of the page where the users links are displayed.
// Example: [url]http://www.yoursite.com/index.php/[/url]
$loc = "http://www.darpac.com/~robert/favorites/";
// How long do you want the users cookies to save their
// favorite links? In seconds. Day=86400 Week=604800
// month=2419200 year=29030500
$exp = 29030500;
if ($state == "update") {
setcookie("favorite[1]", $fav1, time()+$exp);
setcookie("favorite[2]", $fav2, time()+$exp);
setcookie("favorite[3]", $fav3, time()+$exp);
setcookie("favorite[4]", $fav4, time()+$exp);
setcookie("favorite[5]", $fav5, time()+$exp);
$state = "done";
header("Location: $loc");
} else {
if (strlen ($favorite[1]) < 3) setcookie("favorite[1]", "www.robscripts.com", time()+300000);
if (strlen ($favorite[2]) < 3) setcookie("favorite[2]", "www.digitaledge.com", time()+30000);
if (strlen ($favorite[3]) < 3) setcookie("favorite[3]", "www.penpalseek.com", time()+300000);
if (strlen ($favorite[4]) < 3) setcookie("favorite[4]", "www.budgetideas.com", time()+300000);
if (strlen ($favorite[5]) < 3) setcookie("favorite[5]", "www.cardfan.com", time()+300000);
}
?>
<html>
<head>
<title>Favorites</title>
</head>
<body>
Update Favorites:
<form method="POST" action="update.php">
<?
for ($x = 1; $x <= 5; print "$x: <input type='text' name='fav$x' size='29' value='$favorite[$x]'><br>", $x++);
?>
<input type="hidden" value="update" name="state">
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
now run the index.php in your loclhost
and test the cookies have fun

