This is not your average session failed to start question, there is no whitespace, i have not called it in another file etc.
Im currently working on an application as I have started to build my session library, now when I call session_start I get the following error:
A session had already been started – ignoring
session_start()
For those who wish to see the source: https://github.com/AdminSpot/ASFramework/blob/master/system/libraries/session.php
This usually means that the session.autostart directive is set to 1, but that’s the thing.. it’s not, it’s set to 0 and I have verified this by doing the following:
- Search my entire system for
php.ini*files, checked them - Executed the following command
php --iniamd validated the ini files - executed the following command
php -i | grep session.auto_start. which responded withsession.auto_start => Off => Off - Checked the PHPInfo page, see image below
- Checked the php.ini files for cgi
- There is no htaccess files on nginx
grep -lir "session_start" *only shows my library file- Restarting FastCGI, Nginx and the entire server
I have created a basic test script to test where i have just called session start on it’s own.
The phpinfo() call stats the active php.ini is /etc/php5/cgi/php.ini so after running cat /etc/php5/cgi/php.ini | grep session.auto_start I get session.auto_start = 0, so it disabled, Could it be NGinx ?
Has anyone got any idea what’s going on, some server information below:
- PHP: PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch
- MySQL: Ver 14.14 Distrib 5.1.54, for debian-linux-gnu (i686) using readline 6.2
- Nginx: Version: nginx/0.8.54
PHPInfo screen:

My first guess would be that you have an auto-prepend file or an .htaccess which is modifying the settings in the meanwhile.
You can use
ini_getto retrieve the value of session.auto_start and auto_prepend_file to confirm. phpinfo() should work too.Edit
Could it be that your session library is being instantiated twice? Since return
$this->session_startedis an instance variable, that could cause issues. What happens if you set that to a class-level variable?Side note:
You also have this
return $this->session_started = true;at the end of thestart()method. It shouldn’t matter, but it looks funny.