Page 1 of 1

Newbie can't set a cookie

Posted: Mon Mar 01, 2004 10:08 am
by Joe
Hello, Recentlt I have been working on a PHP login script for my website. I want to set a cookie for the username of the person who logs in but every time i try it i get a PHP error in my browser. The error goes like:

Warning: Cannot modify header information - headers already sent by (output started at /home/.sites/27/site244/web/scripts/login.php:3) in /home/.sites/27/site244/web/scripts/login.php on line 5

The PHP code at the top of the document simply gos like:

<?php
$username = $_POST["username"];
setcookie ("username", $username, time()+36000);
?>

Then its the html tags and some more php throughout the rest of the script. What am i doing wrong here. Has anyone ever had a similar problem and they have a little time to help me. Thanks!

Regards



Joe :(

Posted: Mon Mar 01, 2004 10:13 am
by redhair
Reminds me of this post: viewtopic.php?t=1157