登录和注销按钮的会话 [英] session for login and logout button

查看:82
本文介绍了登录和注销按钮的会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在单行中保存当前日期的登录和注销时间。任何人都可以在C#中分享对我有帮助的编码。

I want to save the login and logout time in current date within single row. Could any one share the coding in C# that will help me.

推荐答案

你好会员8110943,



当用户被重定向到注销登录页面时,登录会再次获取注销时间,这不是问题吗?



无论如何,我会建议您只使用两个不同的页面,只需添加一个用于注销。



干杯,

Edo
Hello Member 8110943,

Isn''t the problem that when the user is redirected to the login page for the logout the login gets the log out time again?

Anyway, I''d suggest that you simply use two different pages, just add one for the log out.

Cheers,
Edo


您可能会在数据中发现一些异常,因为并非每个人都会通过您的网站注销。当用户只是离开您的网站或关闭浏览器时,大多数注销都会发生。在这些情况下,您不会获得可以应用于系统的显式注销。

但是,基本逻辑是在登录时离开注销时在数据库中创建登录行值为NULL的字段。(我假设你已经从你的问题中得到了类似的东西)

注销时,我建议您只需要提取当前的最新登录记录注销日期为NULL的用户,只需将当前时间写入该记录。如果没有找到记录,那么只需忽略退出请求并假设用户根本没有登录。

但请不要忽略我的答案的第一部分。如果你没有写一些东西来清理这些流氓记录,那么会有很多事情会弄乱你的数据。
You may find some anomalies in your data because not everyone will log out through your site. Most logouts will occur when uses simply navigate away from your site or close their browser. In these cases, you won''t get an explicit logout that you can apply to your system.
However, the basic logic would be to create the login row in your database when they login leaving the logout field with a value of NULL.(I''m assuming you already have something like that from your question)
On logout, I would suggest that you just need to pull the latest login record for the current user where the logout date is NULL and simply write the current time to that record. If no record is found, then just ignore the logout request and assume the user isn''t logged in at all.
But please don''t ignore the first part of my answer. There are many things that will happen to mess up your data if you don''t write something to clean up these rogue records.


这篇关于登录和注销按钮的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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