如何最好地实施“收藏夹”功能特征? (就像数据驱动网站上最喜欢的产品)

发布于 2024-09-02 08:03:15 字数 631 浏览 4 评论 0原文

我编写了一个动态数据库驱动、面向对象的网站,带有管理前端等。我想添加一个功能,客户可以将项目保存为“收藏夹”,而无需创建帐户和登录,以便稍后返回它们,但我不知道具体如何执行此操作...我看到三个选项:

  1. 根据 IP 地址记录收藏夹,然后如果客户随后创建帐户,则将其更改为针对帐户进行记录;
  2. 强制客户创建一个帐户才能使用此功能;
  3. 根据 IP 地址记录收藏夹,但用户可以选择以指定的名称保存收藏夹。

选项 1 的问题是我对 IP 地址了解不多 - 我爸爸认为它们是独一无二的,但我知道人们在使用此类系统时遇到过问题。

1和2的问题是账户还没有向客户开放——目前只有管理员可以登录。改变它应该很容易(不超过上午或下午的工作),但我也必须实现用户组。

选项 3 的问题是,如果用户 A 保存了一个名为“我的收藏夹”的收藏夹列表,然后用户 B 尝试以该名称保存列表但遭到拒绝,则用户 B 将能够访问用户保存的列表A 因为他们现在知道它已经存在。解决这个问题的一个解决方案是使用密码保护列表,但为了付出所有这些努力,我也可以实施选项 2。

当然,我总是可以使用选项 4;如果有人可以提出比上述任何选项更好的解决方案,请使用替代方案。

那么以前有人做过这样的事情吗?如果是这样,你是怎么做的?您推荐(或不推荐)什么?

I have written a dynamic database driven, object oriented website with an administration frontend etc etc. I would like to add a feature where customers can save items as "favourites", without having to create an account and login, to come back to them later, but I don't know how exactly to go about doing this... I see three options:

  1. Log favourites based on IP address and then change these to be logged against an account if the customer then creates an account;
  2. Force customers to create an account to be able to use this functionality;
  3. Log favourites based on IP address but give users the option to save their favourites under a name they specify.

The problem with option 1 is that I don't know much about IP addresses - my Dad thinks they are unique, but I know people have had problems with systems like this.

The problem with 1 and 2 is that accounts have not been opened up to customers yet - only administrators can log in at the moment. It should be easy to alter this (no more than a morning or afternoons work) but I would also have to implement user groups too.

The problem with option 3 is that if user A saves a favourites list called "My Favourites", and then user B tries to save a list under this name and it is refused, user B will then be able to access the list saved by user A because they now know it already exists. A solution to this is to password protect lists, but to go to all this effort I may as well implement option 2.

Of course I could always use option 4; use an alternative if anyone can suggest a better solution than any of the above options.

So has anyone ever done something like this before? If so how did you go about it? What do you recommend (or not recommend)?

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

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

发布评论

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

评论(1

暮年慕年 2024-09-09 08:03:15

使用基于 IP 的解决方案的问题是 IP 不一定是唯一的。路由器允许多个人使用一个“外部”IP 地址(您的网站将看到该地址)访问互联网,并为每个用户提供一个唯一的“内部”地址(您无权访问该地址)。路由器用于公司、教育机构、家庭、提供互联网接入的场所(如咖啡馆)等等。因此,基于 IP 的解决方案并不适合所有人 - 例如,我和我的室友都使用路由器连接到互联网,从而共享一个外部 IP 地址,最终会得到一个双方都可以看到的收藏夹列表。

更好的解决方案是当客户端尝试添加收藏夹时,将一些 GUID 保存到客户端计算机上的 cookie 中。然后在您的数据库中将收藏夹链接到此 GUID,直到用户在您的系统上创建帐户。但这并非没有问题。如果用户从他们的机器上删除cookie,他们将无法访问他们的收藏夹。

最好的选择是让他们在系统上创建帐户,登录后,他们可以创建与其帐户关联的收藏夹。因此,选项 2 将是首选解决方案,特别是对于需要保留到用户选择删除为止的数据。

The problem with using an IP based solution is that IPs are not necessarily unique. A router allows multiple individuals to access the internet using one "External" IP address - which is what your website will see - and provides each user with a unique "Internal" address - which you don't have access to. Routers are used in companies, education institutions, homes, places that offer internet access like cafes, you name it. Thus, an IP based solution wouldn't work for everyone - for example both my roommate and I connect to the internet using a router and thus share one external IP address and would end up with one Favorites List that both can see.

A better solution would be to save some GUID into a cookie on the clients machine when they try to add a favorite. Then in your database you link the favorites to this GUID until the user creates an account on your system. But this isn't without its problems; if the user deletes the cookie from their machine they will loose access to their favorites.

The best option would be to have them create accounts on the system and once logged in, they can create favorites that are associated with their accounts. Thus option 2 would be the preferred solution especially for data that needs to persist until the user opts to delete it.

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