Click to See Complete Forum and Search --> : setcookie()


mg8
11-08-2003, 07:17 PM
I keep getting this error with it:

Warning: Cannot modify header information - headers already sent by (output started at trial.php:10) in trial.php on line 31


Code:
<?
setcookie("loggedin",'no',time() + 3600);
?>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#CCCCCC">
<div class="News"><center>
<? (// line 10)


echo "You have successfully logged in: ".$user;
setcookie("loggedin",'yes',time() + 3600); (// line 31)
if ($_COOKIE['loggedin'] == "yes")
{
echo "Cookie";
}
else
{
echo "No Cookie";
}
exit;



Thanks

YoN
11-08-2003, 07:36 PM
You cannot send html content to the web browser before any headers.
First you have to set the cookie (or the cookies) and then send the whole content of the page

HTH