Code:
<html>
<head>
<title>cookie.php</title>
<head>
<body>
<?php
$id = 10;
if ( isset($_COOKIE["test"]) )
{
$k = $_COOKIE["test"];
print("Vrednost kolacica je $k");
}
else
{
$vreme = time() * 60 * 30;
setcookie("test", $id, $vreme);
}
print("Vrednost \$id = $id!<br />");
print ("<a href='cookie.php'>Ponovo</a>");
?>
</body>
</html>
<html>
<head>
<title>cookie.php</title>
<head>
<body>
<?php
$id = 10;
if ( isset($_COOKIE["test"]) )
{
$k = $_COOKIE["test"];
print("Vrednost kolacica je $k");
}
else
{
$vreme = time() * 60 * 30;
setcookie("test", $id, $vreme);
}
print("Vrednost \$id = $id!<br />");
print ("<a href='cookie.php'>Ponovo</a>");
?>
</body>
</html>
Firefox mi prikazuje stranicu sledeće sadržine:
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\webprog\proba\cookie.php:7) in C:\wamp\www\webprog\proba\cookie.php on line 18
Vrednost $id = 10!
Ponovo
Meni ovaj kod deluje ok, ai očigledno nije. U čemu je problem? Molim vas, pomozite, bijem glavu već ceo dan i nikako da prvalim šta ne valja...