Jump to content

Notice: A session had already been started - ignoring session_start()


dellvostro

Recommended Posts

Im getting the following error for a formmailer from one of my sites. I tested on multiple other hosting servers and I have no notices, errors or problems. This leads me to believe its a hosting issue. Can anyone confirm or advise on how to fix or even suppress or hide notice?

 

Thank you

 

Notice: A session had already been started - ignoring session_start() in /var/www/vhosts/mydomain/httpdocs/formmailer.php on line 1

The truth of the matter is it takes php 10 to 20 times longer to execute a line of code that generates a notice, warning, or fatal error. Suppressing the reporting or display of the error simply masks the problem. It is always best to find and fix the problem instead of trying to fix a symptom.

 

Either your code has more than one session_start() and the error reporting on the servers where it seems to work is set to hide the error message or your code only has one session_start() it would mean that php is setup to automatically start the session on the server where you are getting the error message.

 

For the first possibility, make sure your code only has one session_start() per page (any page that uses sessions should have a single session_start() at the beginning of the page.)

 

For the second possibility, use a phpinfo() statement and check what session.auto_start is set to?

I ran the phpinfo and heres the only session.auto I found. If the values are incorrect, how would I change them?

 

I only have 1 session_start at top of document page. There is a phpdigs java script calling a search box function on page, but I dont see a session_start on this page.

 

 

Directive Local Value Master Value

session.auto_start Off Off

The auto start setting being off means that php is not causing the error. Which means that your code is executing a session_start() more than once. You either have something in a loop or a file is being include more than once...

 

Is the formmailer.php script the target of a form or are you including it into some other file?

 

Was the script with the phpinfo() statement in the same folder where the script generating the error is located (there might be a .htaccess or local php.ini file changing the auto start setting.)

 

There could also be an auto_prepend_file that could be starting the session (some hosts do some unusual things.) What does your phpinfo() show for the auto_prepend_file setting?

auto_prepend_file no value no value

 

i tried using the @ in session_start  but ut didint hie notice. It really baffles me that the form works on a half dozen other servers, but the one I have no control over it doesnt work .

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.