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
  •  | 
  •  

Pergunta

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

Foi útil?

Solução

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

Outras dicas

unset($_SESSION['variable_name']);

or you can also destroy the session to logout.

session_destroy();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top