Irish_Dave Posted April 26, 2021 Share Posted April 26, 2021 (edited) 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 David Edited April 26, 2021 by Irish_Dave Quote Link to comment https://forums.phpfreaks.com/topic/312543-php-warning-session_start-cannot-start-session-when-headers-already-sent-in-and-warning-cannot-modify-header-information/ Share on other sites More sharing options...
Barand Posted April 26, 2021 Share Posted April 26, 2021 See this reply regarding session_start() 1 Quote Link to comment https://forums.phpfreaks.com/topic/312543-php-warning-session_start-cannot-start-session-when-headers-already-sent-in-and-warning-cannot-modify-header-information/#findComment-1586147 Share on other sites More sharing options...
gizmola Posted April 26, 2021 Share Posted April 26, 2021 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: <?php //Somescript.php // 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. Quote Link to comment https://forums.phpfreaks.com/topic/312543-php-warning-session_start-cannot-start-session-when-headers-already-sent-in-and-warning-cannot-modify-header-information/#findComment-1586162 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.