To use cookie-based sessions, session_start() must be called before outputing anything to the browser.

dal manuale di php