我将登录到站点的用户存储在 .txt 文件中。我想在他们直接关闭浏览器时删除他们的姓名。我正在使用 php 代码。他们是删除名称的一种方式吗?
问问题
115 次
3 回答
2
没有万无一失的方法来判断用户是否关闭了他或她的网络浏览器。试图用 JavaScript 捕捉这样的动作无疑会导致错误。您唯一能做的就是在预定义的不活动时间后删除所述用户名。如果用户在预定义的时间范围内没有执行任何操作,则假定它们处于非活动状态。
于 2013-06-21T16:50:46.357 回答
0
To remove the line of the text file in PHP: PHP Remove line containing string from a text file
To make a request on unload: JavaScript, browsers, window close - send an AJAX request or run a script on window closing
于 2013-06-21T16:52:32.770 回答
0
As Wayne said, there's no sure-fire way, but one thing you could do is use JavaScript to check whether the user closed the tab, and then send an AJAX call to a PHP script that deletes the username from the file.
于 2013-06-21T16:53:07.170 回答