Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logout and redirecting session in php

Tags:

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();
?>
like image 792
Dinesh Kumar Avatar asked Sep 11 '25 04:09

Dinesh Kumar


1 Answers

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");
like image 175
devasia2112 Avatar answered Sep 12 '25 18:09

devasia2112