Need help with sessions

if( isset($_SESSION) ):
  // prevent warnings
else:
  session_start();
endif;

This is pretty old-school. New-school is:

if (session_status() !== PHP_SESSION_ACTIVE) {
  session_start();
}

See https://www.php.net/manual/en/function.session-status.php

4 Likes