I ve binged a lot for this stuff, but couldn t find direct ANSWER, I ve searched for this here,
But I am still beating my head against the wall trying to implement,
How do I do update query after session expired? I m not talking about explicit clicking "Logout" button
基本 SQL 结构 :
CREATE TABLE auth_users (
email varchar(40) NOT NULL,
password varchar(40) NOT NULL,
online ENUM( 1 ) DEFAULT NULL <-- HERE, it updates to 1 when user logged in, it updates back to NULL when user explicitly clicks on LOGOUT
) type=MyISAM;
Class Hierarchy:
interface {
function login();
function logout();
//calls after succes authorization
function set_as_online();
//calls from within logout() method
function set_as_offline();
}
但它不更新 返回到NULLLL,当用户关闭 他的布朗,
For example, Assume we have two users: User-A, User-B
用户 A 已登录成功, 现在用户B 可以将用户A 视为 ONLINE 用户 。
If User-A forget to click "LOGOUT" and would close his browser, user-B still can see User-A as ONLINE. That s the problem.
For example, Facebook handles this very well,
Assume your friend just closed the browser (i.e his session does not exists anymore), then somehow you can see him as OFFLINE
我做错什么了? 处理离线/在线用户的方法不正确吗?