Reputation: 2266
I can't figure out why ,anyone any help?
Upvotes: 2
Views: 152
Reputation: 11278
simple: session_start sets your php session cookie, and cookies can only be set in the http header. php must send the header before it can start sending content. so as soon as you start to output content, php implicitly sends the http header and thus disables changing header values.
a common way to prevent this is to use output buffering - see http://php.net/manual/de/ref.outcontrol.php
Upvotes: 6