user1400702 user1400702 - 6 months ago 12
PHP Question

PHP sessions that have already been started

In my PHP code, if a session has already started, and I try to start a new one, I get the following Notice:


Notice: A session had already been started - ignoring session_start()


How can I avoid this?

Answer

Try

<?php
    if(!isset($_SESSION)) 
    { 
        session_start(); 
    } 
?>