管理匿名用户的最佳实践 数据

发布于 2024-07-16 08:02:18 字数 579 浏览 14 评论 0原文

我正在寻找有关推荐的或简单尝试和测试的将数据与 Web 应用程序中的匿名用户关联的方法的任何提示。 我希望用户可以在多个会话中使用数据,因此将其存储在数据库中。

显然我需要某种 cookie 来识别该用户,我特别感兴趣的是如何管理这个匿名标识符和实际数据之间的链接。 到目前为止,我正在探索两个选项:

  1. 创建持久匿名用户 与每一位独特的访客。 这边走 我的数据不需要关心是否 它属于匿名用户或 注册了一个,它只是属于一个 用户。
  2. 有某种包装器/管理器 对于使用自己的数据 要关联的唯一 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:

  1. 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.
  2. 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 技术交流群。

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

发布评论

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

评论(2

无名指的心愿 2024-07-23 08:02:18

保留匿名用户是没有意义的,原因有两个:

  1. 今天的内容明天就消失了。 您将留下大量孤立的行,您必须时不时地进行整理。
  2. 持久化到数据库意味着您可以为这些用户进行大量自定义,这是一个坏主意,因为它们都挂在 cookie 上

我建议不仅使用 cookie 来跟踪它们,还可以将其用作数据存储。 或者选择第二种,您可以与注册用户分开处理它们。

It doesn't make sense to persist an anonymous user for two reasons:

  1. Here today gone tomorrow. You'll be left with lots of orphaned rows which you'll have to rake every now and then
  2. Persisting to a DB would imply that you can do a lot of customizations for these users which is a bad idea because it's all hanging by a cookie

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.

倚栏听风 2024-07-23 08:02:18

我可能会选择情况 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.

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