Dinesh Kumar Dinesh Kumar - 8 days ago 5
PHP Question

logout and redirecting session in php

the below one is the link in my php site.. after clicking this button the user's session should be terminated and he should be redirected again to the home page.. i have written the coding for this concept as follows but it shows me only a blank page(it is not redirected to the home page)..
please correct my codings

<a href="Logout.php">
click here to log out</a>


codings in the Logout.php a follows

<?
session_start();
session_unset();
session_destroy();
ob_start();
header("location:home.php");
ob_end_flush();
include 'home.php';
//include 'home.php';
exit();
?>

Answer

Only this is necessary

session_start();
unset($_SESSION["nome"]);  // where $_SESSION["nome"] is your own variable. if you do not have one use only this as follow **session_unset();**
header("Location: home.php");
Comments