In my php project when I clicked on logout, I am redirecting at home page, and if I click back button I am getting back in account page

StackOverflow https://stackoverflow.com/questions/23511224

  •  16-07-2023
  •  | 
  •  

Question

In my php project when I clicked on logout, I am redirecting at home page, and if I click back button I am getting back in account page, I dont wont to let anyone to come back in account once they clicked logout, which is the best way to do this?. please rply. Thnx

Was it helpful?

Solution

Destroy the session:

session_unset();//Unset all session variables
session_destroy();

And maybe redirect users if they don't have a valid session. Add in your header something like

if(!isset($_SESSION['valid_user'])){
//Go to some other page
header("Location:$homepage");
}

OTHER TIPS

unset($_SESSION['variable_name']);

or you can also destroy the session to logout.

session_destroy();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top