How to check PHP session has already started or not

when we start session useing session_start() function on a script sometimes we can get the error message "session already started". the better way to check if session has already started or not.

Recommended way for versions of PHP >= 5.4.0

<?php
if (session_status() == PHP_SESSION_NONE) {
  session_start();
}
?>

Recommended way for versions of PHP < 5.4.0

<?php
if (session_id() == '') {
  session_start();
}
?>

Source: http://www.php.net/manual/en/function.session-status.php