管理匿名用户的最佳实践 数据
我正在寻找有关推荐的或简单尝试和测试的将数据与 Web 应用程序中的匿名用户关联的方法的任何提示。 我希望用户可以在多个会话中使用数据,因此将其存储在数据库中。
显然我需要某种 cookie 来识别该用户,我特别感兴趣的是如何管理这个匿名标识符和实际数据之间的链接。 到目前为止,我正在探索两个选项:
- 创建持久匿名用户 与每一位独特的访客。 这边走 我的数据不需要关心是否 它属于匿名用户或 注册了一个,它只是属于一个 用户。
- 有某种包装器/管理器 对于使用自己的数据 要关联的唯一 cookie 值 与数据。
#1 的主要问题是创建的用户数量。 每 24 小时运行一个脚本来清理表很容易,但我仍然可以每天创建数千行(我希望!),将它们保留 14 天会产生很多结果。 对于#2,我必须构建一个特定于数据的匿名/基于 cookie 的基础设施,但是当我有其他需要相同功能的数据集时会发生什么。
有人对如何做到这一点有任何最佳实践建议吗? 我正在使用 NHibernate 进行 ASP.NET MVC 工作,但是来自任何平台的概念和想法都会有所帮助。
I'm looking for any hints on recommended, or simply tried and tested, ways of associating data with an anonymous user in a web application. I want the data to be available to users across multiple sessions, so therefore store it in the database.
Obviously I will need some kind of cookie to identify that user, what I'm particularly interested in is how to manage the link between this anonymous identifier and the actual data. So far I am exploring two options:
- Creating a persisted anonymous user
with each unique visitor. This way
my data doesn't need to care whether
it belongs to an anonymous user or
registered one, it just belongs to a
user. - Have some kind of wrapper/manager
for the data that uses its own
unique cookie value to associate
with the data.
The main issue with #1 is the number of users getting created. Running a script every 24 hours to clean the table out would be easy, but I could still be creating thousands (I hope!) of rows per day, keeping them for say 14 days would result in a lot. With #2 I have to build an anonymous/cookie-based infastructure thats specific to the data, but what happens when I have other sets of data that need the same functionality.
Does anyone have any best-practice advice on how this might be done? I'm working in ASP.NET MVC with NHibernate, but concepts and ideas fom any platform would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
保留匿名用户是没有意义的,原因有两个:
我建议不仅使用 cookie 来跟踪它们,还可以将其用作数据存储。 或者选择第二种,您可以与注册用户分开处理它们。
It doesn't make sense to persist an anonymous user for two reasons:
I would suggest either using the cookie not only to track them, but also as a data store. Or option two where you handle them separately from registered users.
我可能会选择情况 1。每天几千行只是少量数据,您不应该担心。 这听起来像是一种情况,您只是让它工作起来,然后再担心性能(可能永远不会)。
您可能永远无法清除它,但仍然不会遇到问题。
I would probably go for case 1. A few thousand rows a days is a small amount of data, not something you should worry about. This sounds like a one of those cases where you just get it working and worry about performance later (probably never).
You could probably never clear it out and still never run into problems.