Hello. As you can tell, this is my first post on this forum. Let me assure you that I've searched for solutions on this problem already. I still haven't found a working solution. This is probably the biggest PHP headache I've had so far. And, it's the first time I've ever needed some serious help. Now, on to the problem...
I have a login/logout script that I wrote for a website I am developing. It has all of the headers to disable cache. It uses session unset, destroy, etc. to remove a session when the user clicks the logout button. However, when they click the back button, they are taken to a page that says that "this page has expired". If you refresh, the browser asks if you would like to resend the information. I click yes, and my session is created again, and the username and password are validated.
My first thought was to set $loggedIn to false if no session is found. This skips all of the secure information and display the page with a prompt for a username and password.
I thought I had solved my problems, but woe is me. Now, if you click back you get an expired page. Refresh once and there are no problems. Refresh again and you the username and password authenticates.
I've tried various solutions. I've created a cookie for the session. I've tried creating a file. What I've realized is that all methods produce the same result.
The best solutions I can come up with right now is to save the session ID to the database. If the session ID is equal to the username in my session, do not allow a login. This works for me, but produces a different problem. If I limit one login per session ID, the user can logout, but they cannot login again unless they open a new window, creating a new session ID. If i register a new session ID when the user logs out, the "click back and refresh" hack will work again.
So, are my users doomed to only being allowed to login once per window?