timed auto logout and browser close

后端 未结 6 1164
温柔的废话
温柔的废话 2021-01-19 15:29

I\'ve created a very simple multiuser game for learning purposes.

As users log on, each other user gets an update of all currently logged in users.

When a us

6条回答
  •  礼貌的吻别
    2021-01-19 16:04

    Don't know about the first question, but how about a suggestion on the second:

    When the user is 'active', will they be causing page requests fairly regularly? If so, you could have a system whereby a logged-on user is periodically logged in your SQL database, with a timestamp. Then have another script look up all those users whose timestamps are older than a specified period (whatever you like, eg 10 seconds) and have them set to '0'.

    I could suggest some code but maybe this isn't what you're looking for - let me know.

    EDIT: OK, the link from your edit seems to have been answered with a similar system to what I just suggested. If you use AJAX you can call a php script periodically in the background to set and check timestamps from the SQL table.

提交回复
热议问题