我正在asp.net C#中工作。
我有一个用户登录页面,其中包含用户ID,密码字段和“转到”按钮。
登录后,用户进行mcq测试,然后单击页面角落处的“注销”链接退出。会话在用户单击“转到”按钮时开始,并在用户单击“注销”链接时结束。
我想将此会话的开始时间和结束时间保存为日期时间格式的LoginTime和LogoutTime,保存在sql数据库中。
提前致谢。
尝试以下方法:
以下代码将设置为处理登录连接的Web表单:
/* Function which handle login */
// ...
Session["startTime"] = /* get the current time here */;
/* End function which handle connection */
并将此放置在处理注销的Webform上:
/* Function which handle logout */
Session["endTime"] = /* get the current time here */;
/* Insert your date in your database, and carrying the date format */
Session["startTime"] = "";
Session["endTime"] = "";
/* End Function which handle logout */
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句