Skip to content

Instantly share code, notes, and snippets.

@maxixo
Created January 24, 2026 01:20
Show Gist options
  • Select an option

  • Save maxixo/9f3cec32f4667c630b9d418ffb2d00c3 to your computer and use it in GitHub Desktop.

Select an option

Save maxixo/9f3cec32f4667c630b9d418ffb2d00c3 to your computer and use it in GitHub Desktop.
logout in php
<?php
session_start();
if(!isset($_SESSION['user_id'])) {
header("location: logn.html");
exit;
}
echo "Welcome to your dashboard";
?>
<form action="logout.php">
<button>Logout</button>
</form>
<?php
session_start();
session_destroy();
header("Location: login.html");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment