I want to make an auto-logout system for my site for if someone unexpectetly closes browser or shuts-down computer so... what is the best way to make that system? im using php on my site for everything. thanks!
You can store your user's session datas via $_SESSION If user close browser, user's session datas will be removed.
if you unexpectedly shut down the browser or client system, the server will remain blissfully unaware of the event. Ultimately, the session will expire and the problem should cease to be a problem.
The only js-based autologout would be like a timeout, where after a certain period of inactivity, the client would redirect to the server's logout url... but of course this requires the client machine to be online.
php sessions are the way to go. By default: if someone closes their browser they are closing the session, and a timeout can be placed on the session so that inactive sessions are timed out, there is a default time-out of (someone correct me!) about 20 minutes.
But I guess from your level that you are confusing a number of concepts, and you might like to try to think about what it is you are trying to 'prevent'. Security is a much more complex subject area and "auto-log out" is just skirting around the edge of the subject.
精彩评论