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

سؤال

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

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

unset($_SESSION['variable_name']);

or you can also destroy the session to logout.

session_destroy();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top