I was searching for a specific topic but I found nothing that I was looking for. I'm using a php code for logout the user:
<?php
if(!isset($_SESSION))
{
session_start();
}
session_unset();
unset($_SESSION["id"]);
unset($_SESSION["sign"]);
unset($_SESSION["lang"]);
unset($_SESSION["usertype"]);
session_destroy();
echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=./index.php?lang=en">';
?>
And all is working fine except one annoying thing that I would like to avoid. When user presses a log-out button it can be observed that before initial page is shown the additional blank page appears for a while... Can this behaviour be eliminated? - I don't want to show anything in the meantime, I want to just redirect the user to a home page.
Try to replace the line:
echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=./index.php?lang=en">';
With the following function call , and of course, provide your url parameters in order to perform only the php redirect inestead of triying to refresh the page.
Redirect("index.php");
function Redirect($url, $statusCode = 303)
{
header('Location: ' . $url, true, $statusCode);
die();
}
instead of unset()
all variable just use session_unset()
& session_destroy()
for unsetting and destroying all session variables then use header to redirect to home page
session_unset();
session_destroy();
header('Location: http://yourwebsite.com');