I'm using PHP 7.1 and received the following warning when implementing Example #1, above:
PHP message: PHP Warning: session_destroy(): Trying to destroy uninitialized session in...
What I discovered is that clearing $_SESSION and removing the cookie destroys the session, hence the warning. To avoid the warning while still keeping the value of using session_destroy(), do this after everything else:
if (session_status() == PHP_SESSION_ACTIVE) { session_destroy(); }