Notice: A session had already been started – ignoring session_start() in .. on line ..

For an error like this

Notice: A session had already been started – ignoring session_start() in .. on line ..

This happens when you try to start session more than once.

The solution for above problem is

1) in php.ini file set session.autostart to 0

session.auto_start = 0

2) In your code use this line

if (!session_id()) session_start();

instead of

session_start();


Comments

10 responses to “Notice: A session had already been started – ignoring session_start() in .. on line ..”

  1. mocabilly Avatar

    I was told that, to get the session started, nothing, not
    even a blanc line was allowed “before” the session_start() function call..

    Will the session still be started properly?

    1. The solution provided above is for the “Notice: A session had already been started – ignoring session_start() in .. on line ..” problem.

      A blank line above session_start() would matter. After all it is a php code and in php blank lines are allowed.

  2. Thank you very much… yeah its working fine for me

  3. Thanks, i’ts solved my problem.
    Thank you very much

  4. thanks, man.

  5. thank you…it worked…

  6. Pritam Soni Avatar
    Pritam Soni

    Thanks for the help.. worked for me after searching a lot!

  7. Hadrian Sabino Avatar
    Hadrian Sabino

    At last, I have been looking all over until this solution here. It works!

  8. Put ob_start(); at the top of your index file or header file.

  9. Thanks man, this work on my site

Leave a Reply

Your email address will not be published. Required fields are marked *