I use SimpleUsers Class and created a database-based login system. Here is SimpleUsers on Github
Here is my question: How to terminate PHP session on windows close? When the windows closed the session for logged in user is open yet. How can I close it? I tried to use
session_set_cookie_params(0);
But it was not helpful. Please help me.
I assume that by "windows" you mean tab of the browser/window of web browser.
Simple answear is: you can't unless user requests. You can try some kind of javascript code with "onclose" method that will send request to your site to close session. Cons of this method is when someone have 2 tabs and at last one is closed, he will be logged out
You should only destroy sessions only when someone hits Logout button.
Edit to comments
If you want to secure (bind) session to IP you may want to store in
$_SESSIONIP of user who started session and terminate session if IP changes