What is the difference and most secure way to clear login sessions in PHP? Basically going to call this when a user clicks log out in my application.
I am seeing:
session_destroy()
session_unset()
Or simply doing:
unset($_SESSION['my_key_1']);
unset($_SESSION['my_key_2']);
What is the best way?
session_destroy is deleting whole session.
session_unset delete ony a variables from session – session still exist. Only data are truncated.
So, If you want to make memory free session_destroy is best.