Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser back button after log out

How can i prevent browser using the cached copy of the page after log out ?

When user logged out still they can access the previous pages by using the back button.

I understand that we cannot disable the back button (as per SO answers).

Currently i have a large number of pages in different scenarios so i cannot modify each and every page.

What i have tried

  1. Setting the expire header (do i need to set this on each and every page ? also if i do this does browser cache the page contents ? ( because i need the browser to cache contents if user is logged in ))
  2. I have already a polling system ( but still there is a delay to detect )
  3. Javascript based solution ( it works, but still users can use history option to navigate or a long press in back button )

I am really stuck here , Could you please help me to solve the problem ?

like image 716
Red Avatar asked Jul 22 '13 04:07

Red


1 Answers

I think this code will help you, use this code in parent controller constructor.

//Log out Back
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.
like image 156
Jagan Akash Avatar answered Sep 30 '22 00:09

Jagan Akash