I have a site I am developing but I keep encountering the same issue.
The system uses a mySQL database structure to store user details and therefore I have created a PHP page that evaluates the login process.
This evaluation section is at the top of the index.php page as a require_once call. The actual webpage then loads, including the login box. Currently I simply want the system to evaluate as correct the log in and then return to the index.php page.
So, the code is working. I type in the username and password, click submit and it then reloads the index.php page. But I then get the error message:
Warning: Cannot modify header information - headers already sent by...
I know this is down to the reusing of session_start but how do I get the system to evaluate that the session_start has already been called and so not to do it again; avoiding the error altogether?
How to control session_start
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: How to control session_start
You are getting that error because there is some output occurring before the session_start() is called. It can be a space or return before or after your <?php ?> in some file. Any output will force headers to be sent.
(#10850)
Re: How to control session_start
Sorry, do not seem to have explained myself very well. This system works fine first time round BUT, once someone logs in the page needs to reload and, of course, a session_start has already been declared (as well as an entire webpage being sent across). How do I instruct the system NOT to send a new session_start once the person has logged in?Christopher wrote:You are getting that error because there is some output occurring before the session_start() is called. It can be a space or return before or after your <?php ?> in some file. Any output will force headers to be sent.
SESSION START
INDEX PAGE LOADS
USER LOGS IN
SYSTEM RELOADS INDEX PAGE
ERROR OCCURS HERE!