0

After loging in from the homepage and loging out from the welcome page, refreshing the site redirect me to the welcome page.

i'am running MySQL on alfahosting.de server

i've used the unset($_SESSION) but it's seems not working

session_start();

$error = "";

if(array_key_exists("logout", $_GET)){

    unset($_SESSION);
    setcookie("id", "", time() - 60*60);
    $_COOKIE["id"] = "";

}else if((array_key_exists("id", $_SESSION) AND $_SESSION['id']) OR 
array_key_exists("id", $_COOKIE)){

header("Location: loggedinpage.php");

}

there are no error messages, only the redirecting from the homepage to the welcome page after loging out from welcomepage

Webdeveloper_Jelle
  • 2,868
  • 4
  • 29
  • 55
brahim
  • 1
  • And the actual expected behavior would be …? The code you have shown, is that a single script called only once, is it an include file embedded into every “page”, or - what? Please go read [ask], and provide us with a [mre] that properly shows what you are doing. – 04FS Jun 04 '19 at 12:29

1 Answers1

0

When you go to logout you have to destroy the session with

session_destroy ()

I hope it helps you

David
  • 166
  • 1
  • 10