Check if PHP session has already started -
i have php file called page has started session , page doesn't have session started. therefore when have session_start() on script error message "session started". i've put these lines:
if(!isset($_cookie["phpsessid"])) { session_start(); } but time got warning message:
notice: undefined variable: _session
is there better way check if session has started?
if use @session_start make things work , shut warnings?
recommended way versions of php >= 5.4.0
if (session_status() == php_session_none) { session_start(); } source: http://www.php.net/manual/en/function.session-status.php
for versions of php < 5.4.0
if(session_id() == '') { session_start(); }
Comments
Post a Comment