COMPUTER LEARNING CENTER
WWW.HUUKHANG.COM
<h4>UnRegister Session</h4>
<?php
session_unregister("fullname");
if(session_is_registered("userid"))
echo "UserID: ". $userid."<br>";
if(session_is_registered("email"))
echo "Email: ".$email."<br>";
if(session_is_registered("fullname"))
echo
"FullName:
".$fullname;
if(session_is_registered("address"))
echo "Address: ".$address;
?>
</BODY>
</HTML>
Khi trieäu goïi trang sessionunregister.php treân trình duyeät thìkeát quaû traû veà nhö hình 5-
6.
Hình 5-6: Loaïi boû session
Trong tröôøng hôïp loaïi boû taát caùc session ñang toàn taïi thì söû duïng haøm session_unset().
Ví duï duøng haøm naøy ñeå laïoi boû session vaø duøng haøm sessin_destroy ñeå huyû taát caû
session ñoù khai baùo trong trang unset.php nhö ví duï 5-7.
Ví duï 5-7: Xoaù taát caû session
<?php
session_start();
?>
<HTML>
<HEAD>
<TITLE>::Welcome to PHP</TITLE>
</HEAD>
<BODY>
<h4>UnSet Session</h4>
<?php
session_unset();
session_destroy();
if(session_is_registered("userid"))
Giaùo vieân: Phaïm Höõu Khang