I'm working on a login system for a site and just want to make sure that my actual login and logout core functions are correct.
To login I have:
session_start();
session_regenerate_id(true);
$_SESSION["user"] = $username;
$_SESSION["startTime"] = time();
Then later to logout I have
unset($_SESSION["user"]);
unset($_SESSION["startTime"]);
session_destroy();
Is this correct or can this be improved in any way? And can someone clarify what session_regenerate_id(true) is really doing? I inherited it from some preexisting code.