Hie Guys. in this above video, we are learning about how to make a logout system in PHP
As per the video, we have already downloaded the files and linked the CSS and JS.
Step 1: Create a page and paste the below code where you want to set the Logout Button :
<form action="logout.php" method="POST">
<button type="submit" name="logout_btn" class="btn btn-primary">Logout</button>
</form>
Step 2: Create a page with the name logout.php and paste the below code.
<?php
session_start();
if(isset($_POST['logout_btn']))
{
session_destroy();
unset($_SESSION['username']);
header('Location: login.php');
}
?>
i cannot logout sir.
ReplyDelete