1

Possible Duplicate:
php headers already sent error

I've this warning. How can I fix it?

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\AppServ\www\PhpProject1\login.php:2) in C:\AppServ\www\PhpProject1\controller\login.controller.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\PhpProject1\login.php:2) in C:\AppServ\www\PhpProject1\controller\login.controller.php on line 2
Community
  • 1
  • 1
soad el-hayek
  • 63
  • 1
  • 6
  • 4
    This has been answered so many time. Please [search for “headers already sent”](http://stackoverflow.com/search?q=headers+already+sent). – Gumbo May 20 '11 at 18:09
  • The headers_sent function is a good place to start debugging these errors: http://us.php.net/manual/en/function.headers-sent.php – Mark Biek May 20 '11 at 18:13

3 Answers3

1

paste session_start(); in the first line

The Mask
  • 17,007
  • 37
  • 111
  • 185
1

You should also be aware that saving your files in the wrong encoding can produce this error.

http://forums.iis.net/t/1171412.aspx

Jeff Lambert
  • 24,395
  • 4
  • 69
  • 96
0

Session needs to be started before ANY content is printed out. You're echoing something earlier or simply printing something outside PHP tags.

Move your session_start before those print outs. This concerns print outs from ALL your files. It says you even where you've printed stuff out.

output started at C:\AppServ\www\PhpProject1\login.php:2

Tomasz Durka
  • 586
  • 2
  • 9