setcookie returning false
My PHP script, when i do a setcookie command, it returns a false. Any idea on why this would happen?
[CODE]
setcookie("user", $usern, $expire);
[/CODE]
$usern is a string and $expire is a time.
I'm just baffled at why it fails and returns false.
Edit:
I turned on error reporting and it gave me this error message:
Warning: Cannot modify header information - headers already sent by (output started at /home2/infinits/public_html/cs120/login.p hp:3) in /home2/infinits/public_html/cs120/login.p hp on line 30
How would you get around this?
Edit2:
Alright I solved my problem. I just put all the output in a buffer and flushed it all out in the end. ob_start() ob_flush(). Thanx anyways guys.
[CODE]
setcookie("user", $usern, $expire);
[/CODE]
$usern is a string and $expire is a time.
I'm just baffled at why it fails and returns false.
Edit:
I turned on error reporting and it gave me this error message:
Warning: Cannot modify header information - headers already sent by (output started at /home2/infinits/public_html/cs120/login.p
How would you get around this?
Edit2:
Alright I solved my problem. I just put all the output in a buffer and flushed it all out in the end. ob_start() ob_flush(). Thanx anyways guys.
