[ shandu85 @ 15.12.2007. 00:39 ] @
kada otkucam sledeći php kod:
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>


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...
[ x kepa x @ 15.12.2007. 06:15 ] @
Prva rechenica u PHP MANUALu za setcookie() kaze sledeche:
Citat:
setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace.
[ Nemanja Avramović @ 15.12.2007. 13:07 ] @
Već je objašnjeno... http://www.elitesecurity.org/t96073-0#1348151