php - Logout button to unset and destroy the SESSION variables not working -
i have php page in have button login , register. problem in page when log out button not redirected php page of logout unset , destroy session variables.
i providing here code of page can me rectify error.
<div class="wrapper row1"> <header id="header" class="clear"> <!-- banner --> <div id="logo" class="fl_left"> <a href="index.php"> <img src="images\logo.jpg"></a> </div> <div class="fl_right"> <ul class="inline"> <li><i class="fa fa-phone"></i> +91 1234567890 </li> <li><i class="fa fa-envelope"></i> info@hoteldaffodils.com </li> <?php if(isset($_session['email'])) { ?> <li> <?php echo $_session['email']; ?> </li> <li><h1> | </h1></li> <li><h1><i class="fa fa-sign-out"></i> <style="float:right"> <a href="logout.php"> log out </a></h1></li> <?php } else { ?> <li><h1><i class="fa fa-sign-in"></i> <style="float:right" onclick="document.getelementbyid('id01').style.display='block'"> log in </h1></li> <li><h1> | </h1></li> <li><h1><i class="fa fa-user"></i> <style="float:right" onclick="document.getelementbyid('id02').style.display='block'"> register </h1></li> <?php } ?> </ul> </div> </div> </header>
the contents of logout.php given below
<?php session_unset(); session_destroy(); header('location:index.php');
?>
just add line logout.php file:
<?php session_start(); session_destroy(); header('location:index.php'); ?>
destroying session delete session data session_unset()
line unnecessary.
Comments
Post a Comment