我们应该用什么登录?会话或饼干? [英] What should we use for login? Session or cookies?

查看:95
本文介绍了我们应该用什么登录?会话或饼干?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在asp.net中为电子商务和大学网站编写登录代码。我应该选择哪种登录方式。我想继续登录,直到用户关闭浏览器。在这种情况下,我发现难以管理会话。但我也想要安全。我认为我们可以使用db和cookie实现虚拟会话。请建议什么是更好的选择。

解决方案

会话存储在服务器内存中,会话可能会/不会使用cookie来存储内容浏览器。会话基本上是在他的安全上下文中标识用户。 Web应用程序使用会话来识别用户是否经过身份验证等。如果您要存储用户名,登录状态等,请使用会话。


Cookie用于客户端并注明它可以被用户修改。所以你不应该构建一个使用cookie值进行身份验证的应用程序,但同时你可以将它们用于主题,用户语言等(这些是首选,修改它不会影响应用程序的安全性)


I want to write a login code for e-commerce and university website in asp.net. Which method of login I should prefer. I want to continue login till user closes the browser. In this case I found difficult to manage with sessions. But I also want security.I think we can implement virtual session using db and cookie. Please suggest what is better option.

解决方案

Sessions are stored in server memory, and sessions may/maynot use cookies to store something in the browser. Session is basically to identify a user in his security context. The web application uses session to identify whether the user is authenticated.. etc.So use session if you want to store username, login status etc.


Cookies are for client side and be noted that it can be modified by the user. So you should not build an application that uses cookie value for authentication, but at the same time you can use them for themes, user language etc (these are preferencesonly, modifying this will not affect the application secuirty)


这篇关于我们应该用什么登录?会话或饼干?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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