Jump to content

A session had already been started - ignoring session_start()


anujgarg

Recommended Posts

Bricktop, to be descriptive, I am using CodeIgniter and have the statement session_start() at the bottom of the file config.php.

Yes, you are right, this file is being included multiple times on a page.

 

Please let me know what is the solution to get rid of this error.

 

TIA

Anuj

Hi anujgarg,

 

You could simply use @session_start(), the @ would suppress the error but obviously there is still an error occuring and this isn't ideal.

 

if(!isset($_SESSION)) is the correct syntax to use when checking if a session has been started.  Try amending the code in your config.php to be:

 

if(!isset($_SESSION))
{
session_start();
}

 

Then the session will only start if it hasn't already been started.

 

Hope this helps.

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.