I have this basic php script, that doesn’t seem to log me out after a certain amount of time, and I also find myself still “logged in” even if I come back to it again after a certain amount of days
This is obviously a big security risk, as I don’t want someone borrowing my computer (as all my other computers are also used for the same purposes i.e. logging into the admin side of my projects
That’s because the global $_SESSION array will be rebuilt on the next request. You need to unset the session var that you’re using to track the logged in status of the user, eg:
That’s already being called in a method when the “Logout” button is pressed, it’s not all times when I press that button, especially when in a rush to get offline
This should set the session timeout for 30 minutes. This method should be good enough for what you want, although if you want to guarantee that the session expires on time you’ll need to do some extra work.