Including php files gives the error Warning: session_start(): Cannot send session cache limiter - headers already sent

I have some php files that include session start in them, the code will follow.

When I include them on my index page, I get the error

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /Users/adamhewitt/Sites/registration/index.php:10) in /Users/adamhewitt/Sites/registration/register.php on line 8

register.php line 8 is session_start()
and index.php line 10 is include 'register.php'

how do I include something onto another page and manage the session start.

I was hoping to include a log in page as well which also has a session start in it.

Thanks
A

The session_start must be called before you output any content, so just be careful where in the script it appears.

Try testing for 'isset( $_SESSION )`

If it exists then do not use `session_start();’

This is exactly what I did to make it work.

if(!isset($_SESSION)) 
    { 
        session_start(); 
    }

Thanks for your help guys

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.