欢迎光临
我们一直在努力

如何防止同一帐户重复登录系统-ASP教程,ASP应用

建站超值云服务器,限时71元/月

如何防止控制客户端使其用同一帐户重复登录系统.

解决思路:

维护一online表,查看有登陆,就不允许再次登陆,以sessionid作为唯一标识符号,也可以产生一个guid发到cookie中,以区分不同的client,再佐以js,可以达到更好的效果,比如离开后自动离线

解决代码:

public virtual void application_start(object sender, eventargs e)

{

// reset the mailer indicator

application["mailerstatus"] = "all mailings complete";

// initialize a datatable for users online

datatable objusertable = new datatable();

objusertable.columns.add("sessionid",system.type.gettype("system.guid"));

objusertable.columns.add("peopleid",system.type.gettype("system.int32"));

objusertable.columns.add("showdetail",system.type.gettype("system.boolean"));

datacolumn[] pk = new datacolumn[1];

pk[0] = objusertable.columns[0];

objusertable.primarykey = pk;

application["usertable"] = objusertable;

}

/**////

/// the session_start event adds user session information to

/// application["usertable"].

///

public virtual void session_start(object sender, eventargs e)

{

application.lock();

//application.lock ();

datatable objusertable = (datatable)application["usertable"];

datarow objrow = objusertable.newrow();

guid objguid = guid.newguid();

objrow[0] = objguid;

session["pfsessionid"] = objrow[0];

objrow[1] = 0;

objrow[2] = false;

objusertable.rows.add(objrow);

application["usertable"] = objusertable;

application.unlock();

}

/**////

/// the session_end event deletes user session information from

/// application["usertable"].

///

public virtual void session_end(object sender, eventargs e)

{

application.lock();

datatable objusertable = (datatable)application["usertable"];

objusertable.rows.find((guid)session["pfsessionid"]).delete();

application["usertable"] = objusertable;

application.unlock();

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 如何防止同一帐户重复登录系统-ASP教程,ASP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章