Unset()和session_destroy();

<?php session_start();

if(isset($_SESSION["user_name"]))

if($_GET["destroy"]=="yes")

{

unset($_SESSION["user_name"]);

session_destroy();

}


if(!isset($_SESSION["user_name"]) &&

$_GET["user"]!="")

$_SESSION["user_name"] = $_GET["user"];


?>

<html>

<head>

<title>Session Example</title>

</head>

<body>

Welcome <?php echo $_SESSION["user_name"]; ?>

<form action="#">

Input your name here: <input type=text name=user>

<input type=submit value=Submit>

</form>


<form action="#">

<input type=hidden value=yes name=destroy>

<input type=submit value="Destroy Previous Session">

</form>

</body>


</html>

在上面,有两行“ unset($ SESSION [“ username”]); session_destroy();“ 当我删除“ session_destroy();”时 支付与拥有相同。没必要吗?谁能解释这个,任何提示将不胜感激。


翻过高山走不出你
浏览 177回答 3
3回答

撒科打诨

unset()&nbsp;销毁指定的变量。session_destroy()&nbsp;销毁与当前会话关联的所有数据有关更多详细信息,请参见Unset和session_destroy()
打开App,查看更多内容
随时随地看视频慕课网APP