Reputation: 124
I have made a simple user login using php . When the user logs in and presses the back button , I want to log out the user. I figure out that if I am able to clear cache when the back button is pressed , it will fulfill my purpose . I guess clearstatcache() function in php will work . How can I trigger this when the back button is pressed ?
Upvotes: 0
Views: 375
Reputation: 5192
Every time you press the back (or forward) button in a browser, the URL changes, which most of the time means a new request is fired off (from the browser, to the server). You can have a logic that is as follows:
Page 1: Clears all cache, presents user with log-in form.
Page 2: Presents user with logged-in data
If on page 2, the user presses the back button, they will be sent back to page 1, which will clear all cache and present the user with a log-in form.
But this also means that the user cannot do anything in page 2 (like go to page 3), because otherwise, any calls to "back" won't actually go back to page 1.
You can do this. But it's a pretty terrible workflow. My advice is, don't do it, and rather have a "log off" button, that takes the user to page 1 (which will clear cache).
Upvotes: 1