Forum Moderators: coopster

Message Too Old, No Replies

Cookie Error on Login

         

username

3:40 am on Dec 10, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi all, I am setting a cookie when I log a user into my site. I set the cookie the standard way, then redirect them from the login page to the home page. Unfortunately the cookie won't set, and is generating the following error?

My code is:

@setcookie("LoginCookie", $username, time()+60*60*24*30);

Error:

Warning: Cannot modify header information - headers already sent by...

Any ideas?

lokeshshettyk

7:24 am on Dec 10, 2008 (gmt 0)

10+ Year Member



This happens if there is already an output to the screen/browser before the cookie is being set

Try output buffering...

Check for
* ob_start()
* ob_end_flush()

[php.net...]