如何创建数据库驱动的登录系统

发布于 2024-07-25 19:29:10 字数 126 浏览 3 评论 0原文

我想创建一个网站,登录系统不应由 cookie 处理,而应由本地(服务器上)SQL DB 中的表处理。

有办法做到吗? 甚至没有部分方式?

我应该保存什么以及在哪里而不是 cookie ???

I want to create a website that the login system shouldn't be handled by cookies, but on (a) table(s) in the local (on the server) SQL DB.

Is there a way to do it?
Even no partial way?

What and where should I save instead of the cookie???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

感性不性感 2024-08-01 19:29:10

ASP.NET 默认使用会话 cookie 来跟踪用户请求。 如果您使用无 Cookie 会话,您会发现会话 ID 被附加在来自浏览器的所有请求中。 在许多情况下,这也是不可接受的。

即使您决定访问数据库并在每个请求上检查“LoggedIn”标志,您仍然需要某种方法来将传入请求识别为属于特定用户。 这可以是隐藏字段中加密值的形式,具体取决于您的安全场景。 也就是说,这并不是比使用 cookie 更好的方法,因为来自客户端的任何数据都有可能被篡改。

就我个人而言,我认为 Cookie 非常适合跟踪用户请求,只要您正确加密它们即可。

ASP.NET uses Session cookies by default to track user requests. If you use Cookieless sessions, you will find the Session ID being appended in all requests from the browser. In many scenarios, this could also be unacceptable.

Even if you decide to hit the database and check for a "LoggedIn" flag upon each request, you still need some way to identify the incoming request as belonging to a particular user. This could be in the form of encrypted values in hidden fields, depending on your security scenario. That said, it's not a much better method than the use of cookies, because any data that comes from the client has the potential to have been tampered with.

Personally, I think Cookies are great to track user requests as long as you encrypt them properly.

故事灯 2024-08-01 19:29:10

您仍然需要某种方式来区分用户。 如果您不使用 cookie,那么您将必须在 url 中传输该信息,或者只允许来自单个 IP 地址的一个用户(这真的很愚蠢)...或者其他什么。 饼干并没有那么糟糕:-)。

You still need some way of telling the users apart. If you don't use cookies, then you will have to transfer that information in url or allow only one user from a single ip address (this is really stupid) ... or something else. Cookies are not that bad :-).

寻找我们的幸福 2024-08-01 19:29:10

Cookieless ASP.NET

如果您在实际实现登录系统时需要帮助,需要包含有关您的具体问题的更多详细信息。

Cookieless ASP.NET

If you need help actually implementing the login system you'll need to include more details about your specific problem.

迷鸟归林 2024-08-01 19:29:10

您可以将用户名等存储在数据库中,但您仍然需要一种方法来识别用户,因为他/她从一个页面导航到另一个页面。 这就是 cookie 的作用,保存此登录令牌...

可以实现处理此令牌的其他一些方法。 可以使用 URL 或某些隐藏字段(如 ASP.NET 的 ViewState)来存储此令牌。

所以,是的; 可以办到。 但这需要一些工作,因为您无法使用 ASP.NET 已经提供的功能。 (ASP.NET 具有内置功能来将此令牌作为 cookie 进行处理,并将凭据存储在数据库中。)

You can store your usernames and so in a database, but you will still need a way to recognize the user as he/she navigates from page to page. That is the cookies role in this, to persist this login token...

It is possible to implement some other ways of handling this token. One can use the URL or somme hidden fields (as ASP.NET's ViewState) to store this token.

So, yes; it can be done. But it takes some work, since you can't use what ASP.NET already provides you. (ASP.NET has builtin-features to handle this token as a cookie, and also store the credentials in the database.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文