I don't really know what is going wrong. I have my logout page which I redirected to the login folder:
<?php
//include $_SERVER['DOCUMENT_ROOT'].'/connect.php';
include $_SERVER['DOCUMENT_ROOT'].'/functions.php';
if(session_destroy()){
if(isset($_COOKIE['user_name'])){
setcookie("user_name", $user_name, time()-2592000);
}
}
header('location:'.$_SERVER['DOCUMENT_ROOT'].'/login/');
?>
But it always redirects me back to my index page even when I try to run the code like this:
<?php
//include $_SERVER['DOCUMENT_ROOT'].'/connect.php';
//include $_SERVER['DOCUMENT_ROOT'].'/functions.php';
session_start();
if(session_destroy()){
if(isset($_COOKIE['user_name'])){
setcookie("user_name", $user_name, time()-2592000);
}
}
?>
Without including any external page and no header location it still redirects me back to the index page and secondly it doesn't destroy the session after redirecting to the index page until I reload it. Please do any one know the possible cause?
header('location:'.$_SERVER['DOCUMENT_ROOT'].'/login/')- that makes no sense whatsoever. Step 1: Stop confusing file system paths with URLs.