Code below:
$_SESSION = array();
Will it clear all session data? If I wouldn't want to use session_destory().
Code below:
$_SESSION = array();
Will it clear all session data? If I wouldn't want to use session_destory().
Yes, setting $_SESSION to a blank array will essentially unset all existing array keys.
Yup, it will destroy all session data but not the session itself.
Basically, there's three elements to a session:
session_start()$_SESSION['foo'] = 'bar'So you are only destroying the session data. session_destroy() destroys both the data and the session itself, but does not remove the session cookie.
The only "real" difference between $_SESSION = array() and session_destroy() is that after session_destroy(), setting session data will not work anymore before initializing a new session.