简体   繁体   English

是否可以使用cookie制作“添加到收藏夹”功能?

[英]Is it possible to make an “add to favorites” feature using cookies?

I want to make a function using php, where guests can add posts to their favorites (so no signup is needed). 我想使用php创建一个函数,客户可以在其中添加帖子到他们的收藏夹(因此不需要注册)。 I tried using MySQL but I got to a dead end because I couldn't find a way to determine a unique device. 我尝试使用MySQL,但我走到了尽头,因为我无法找到一种方法来确定一个独特的设备。 Some people have told me that I can do the same thing using cookies, can anyone tell me how? 有些人告诉我,我可以用饼干做同样的事情,有谁能告诉我怎么样?

  1. User clicks "favorite this post" button/link 用户点击“最喜欢的帖子”按钮/链接
  2. Using PHP you set the cookie containing favorited post id, along with the already favorites id's that might have been there. 使用PHP,您可以设置包含收藏的帖子ID 的cookie ,以及可能已经存在的已经收藏的ID。
  3. On the "your favorite posts" page you retrieve the cookie and query the database for the id's. 在“您最喜欢的帖子”页面上,您可以检索cookie并查询数据库中的ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM