0

I have been trying for a while to find a method to prevent the the browser from using cached data while the user is logged out. I am trying to force the browser to use the information from the database once the user is logged out instead. This will prevent the back button from exposing information on previously visited pages from being shown. I have used the PHP destroy session. I do not have a clue how to work with REST API.

1 Answers1

0

Well, the REST API doesn't have anything to do with the frontend, but there are ways you can force the frontend page to reload on the back button being pressed.

Here is a similar question.

Essentially, you need to store some local storage data that get's checks on page load and force the page to refresh.

Page One

<script>
     if (sessionStorage.getItem("Page2Visited")) {
          sessionStorage.removeItem("Page2Visited");
          window.location.reload(true); // force refresh page1
     }
</script>

Page Two

<script>
     sessionStorage.setItem("Page2Visited", "True");
</script>

Now, this isn't full-proof. If a user has javascript turned off or has some other block or something in there, it won't work. Companies do not allow sites to control a users browser. And for very good reason. But something like this can be a partial solution for the majority of users.

Community
  • 1
  • 1
Austin Winstanley
  • 1,339
  • 9
  • 19
  • I was hoping to use something that is not Javascript related. I read some place that API can be used so that the browser looks for fresh data from the database instead of cached data. If session destroyed is in affect then the the browsers back button will be rendered ineffective. Therefore, the website's profiles can not be seen if the user is logged out. Wordpress has to be the worst software for creating logged out – ncanquest May 01 '17 at 01:02
  • I tried to adapt your javascript to WordPress but I am getting an error stating that the very 1st curly bracket should not be there, plus I don't have a clue how to represent the home page from WordPress in javascript. Here is my WordPress rendition: – ncanquest May 02 '17 at 06:33
  • Adapted Ur javascript to WordPress but got error saying: 1st bracket shouldnt be there, plus I don't kno how to represent home page from WP in javascript. My WP rendition: – ncanquest May 02 '17 at 06:49