Jump to content

PHP Warning: session_start(): Cannot start session when headers already sent in AND Warning: Cannot modify header information


Recommended Posts

Hi Everyone

I am having a few issues with my website. I have developed in on my xampp local host and it works ok but when I upload the files and try to renew a membership using stripe I get the following messages.

Warning: session_start(): Cannot start session when headers already sent in /customers/a/d/f/mywebsite.co.uk/httpd.www/mywebsite/inc/settings.php on line 2 

Warning: Cannot modify header information - headers already sent by (output started at /customers/a/d/f/mywebsite.co.uk/httpd.www/mywebsite/procedures/payments/charge.php:1) in /customers/a/d/f/mywebsite.co.uk/httpd.www/mywebsite/procedures/payments/charge.php on line 141

I have some includes that appear on every page. This is the bootstrap.php file. This file holds the settings.php which connects to my database and other function files.

In this settings page I call the session_start() php function and then connect to my database.

I call the bootstrap.php file on every page to there for call the session_start() on every page.

I am using sessions alot so is this the right thing to do?

I have attached the renew_membership payment page which holds the form. The user fills out the payment page and the form data gets sent to a script called charge.php which uses the stripe objects to make the payment. I then want to do a redirect to the paymentSuccess.php page to output to the user that the payment was made successfully. This is where the issues arrise. I have split the charge file into 3 screen shots so it is more readable.

Hope someone can help me.

Thanks a lot






















Edited by Irish_Dave
Link to comment
Share on other sites

Please do read the thread that Barand posted.

Somewhere you have started output before the session_start() was called.  That could be via error, or even an errant newline character in an included script.

For this reason, it is recommended that people omit the closing php end tag for scripts:


// Various code

// Don't have an end tag

Carefully check the script where this is happening and insure that the include that does the session_start() is doing that before anything else happens.  Errors will also trigger output in some situations.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.