I have read many php tutorials for logout scripts, i am wondering what could be the proper way to logout from a session!
Script 1
<?php
session_start();
session_destroy();
header("location:index.php");
?>
Script 2
<?php
session_start();
session_unset();
session_destroy();
header("location:index.php");
?>
Script 3
<?php
session_start();
if (isset($_SESSION['username']))
{
unset($_SESSION['username']);
}
header("location:index.php");
?>
Is there any more effective way to do this?? A session can always be created by logging back in, so should i bother about use of session_destroy() and use unset($_SESSION['variable']) instead? which one of the above 3 script is more preferable?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…