如何使用asp.net限制用户每天只登录一次 [英] how can restrict user to login only once in a day using asp.net

查看:130
本文介绍了如何使用asp.net限制用户每天只登录一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用asp.net限制用户每天只登录一次

解决方案

在相关数据库表中有一个日期字段说lastlogin来记录登录的最后日期。每当用户登录并通过身份验证时,请根据他的lastlogin字段检查当前日期,如果它们相同,则拒绝登录,否则,将此lastlogin更新为当前日期。

当用户第一次登录时,您可以使用服务器变量字符串Ip = Request.ServerVariables [REMOTE_ADDR]将登录信息保存在数据库中,就像登录名,登录日期和客户端ID一样。 ToString();



用户登录时第二次可以按日期检查信息,就像login_name或clientIP一样,如果存在,则该用户是否存在,否则不允许登录

how can restrict user to login only once in a day using asp.net

解决方案

Have a date field say "lastlogin" in the relevant database table to record the last date of login. Whenever a user logs in and passes the authentication, then check the current date against the "lastlogin" field of his, if they are the same, then reject his log in, otherwise, update this "lastlogin" to current date.


When user first time login in then You can save login information in your database just like login_name,date when login in and client id by using server variable string Ip = Request.ServerVariables["REMOTE_ADDR"].ToString();

Second time when user login in you can check information by date just like login_name or clientIP this user exist or not if exist then dont allow otherwise login in.


这篇关于如何使用asp.net限制用户每天只登录一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆