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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.