php html wp logout code example
Example 1: logout in php
<?php
if(isset($_GET['logout'])) {
session_destroy();
unset($_SESSION['uname']);
header('location:login.php');
}
?>
Example 2: logout php code
<?php
session_start();
?>
<html>
<head>
<title>User Login</title>
</head>
<body>
<?php
if($_SESSION["name"]) {
?>
Welcome <?php echo $_SESSION["name"]; ?>. Click here to <a href="logout.php" tite="Logout">Logout.
<?php
}else echo "<h1>Please login first .</h1>";
?>
</body>
</html>
Example 3: wordpress wp_logout_url redirect
add_action('wp_logout','auto_redirect_after_logout');
function auto_redirect_after_logout(){
wp_safe_redirect( home_url() );
exit;
}