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

Était-ce utile?

La 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");
}

Autres conseils

unset($_SESSION['variable_name']);

or you can also destroy the session to logout.

session_destroy();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top