Is there a downside to session.auto_start in PHP?

Viewed 15210

I usually end up adding session_start() to the top of every page on my PHP sites (or in a header file which is in turn included on every page). I recently discovered that you can have sessions start automatically by using the following setting in php.ini:

session.auto_start = 1

What are the potential downsides (if any) of using this setting?

2 Answers

Maybe this helps. It will create a session if there is no session created on page load.

if(!isset($_SESSION)): session_start();endif;

If you want to start a specific session, then use something like this:

if(!isset($_SESSION['your_session'])){             
            $data = array('default data');
            $_SESSION['your_session']=$data;
        }
Related