Session Issues

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
User avatar
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Wed Sep 26, 2012 2:35 pm

This usually occurs when you're sending out your headers before hand. ie.. you have like..

include ('headers.php'); // this file that contains <!DOCTYPE HTML.. etc..

is this file being "included" or is it being called from a form?

New php-forum User
New php-forum User
Posts: 109
Joined: Thu May 03, 2012 7:22 am

Thu Sep 27, 2012 1:53 am

If you have any output to the browser in this file, header() won't work.

php-forum Fan User
php-forum Fan User
Posts: 974
Joined: Mon Oct 01, 2012 12:32 pm

Tue Oct 02, 2012 1:12 pm

As they said, any output to the browser before the session_start() will throw error. that includes empty lines before <?php tag, OR if you have other php files included before that one that have trailing empty lines after a ?> closing tag. You can also bypass the error by enabling output_buffering in your php.ini (or manually each time as Harok suggested).

Post Reply