如何显示论坛帖子的未读/已读状态,例如 vbulletin、phpbb 等?
这是一个价值百万美元的问题,我在这里和其他 php 编码相关网站和论坛上一次又一次地看到它,但我从未见过它的答案。
因此,我开始深入研究一些大型高流量论坛如何实现此功能,即向您显示哪些线程中有新的未读帖子,并且它们似乎将线程 ID 号存储到用户 cookie 中。因此,会有一个 cookie,其中包含您在一定时间内读取的每个线程的线程 ID。或者类似的东西。
然后我在这里读到cookie只能存储X个字符,所以我想知道cookie中可以存储多少数据?如果我有 5-6 个字符的 ID 号,那么 Cookie 中可以容纳多少个字符?
This is the million dollar question, I see it time and time again on here and other php coding related sites and forums but I have NEVER seen an answer to it.
So I started digging in and studying how some of the big high traffic forums accomplish this feature of showing you which threads have new unread posts in them and it appears that they store the thread ID number into a user cookie. So there would be a cookie with a thread ID of every thread you have read within a certain amount of time. Or something similar to this.
I then read on here that cookies can only store X amount of characters, so I am wanting to know how much data can be stored in a cookie? If I have a 5-6 character ID number, how many could I fit into a cookie?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
摘自此作者的帖子
我相信对于未读/已读的人论坛帖子的状态应通过数据库来完成。我无法在网上找到示例,但我已阅读 "PHP 和 MySQL Web 开发 (4th Edition)” 并且他们有一个专门用于开发您自己的论坛页面的部分。他们提供示例代码并解释启动过程。
Taken from this author's post
I believe for the unread/read status of forum posts should be done through the database. I could not find an example online, but I have read "PHP and MySQL Web Development (4th Edition)" and they have a section devoted to developing your own forum page. They supply example code and explain the process to get it started.
我不认为他们使用cookie,因为如果你切换计算机,它就不会持续存在(除非它是某些框架提供的基于数据库的cookie)。我假设他们在数据库中有一个关系表,用于跟踪用户查看线程的最新日期。
I don't think they use cookie since that isn't going to persist if you switch computers (unless it's DB-based cookies that some frameworks provide). I'd assume they have a relationship table in the database that keep track of the latest date a user viewed a thread.
ie 中的 cookie 限制:
最多 300 个 cookie
cookie 最多 4096 字节(通过 Set-Cookie 标头的语法描述中构成 cookie 非终端的字符大小来衡量)
每个 每个唯一主机或域名最多 20 个 Cookie
cookie limit in ie :
at most 300 cookies
at most 4096 bytes per cookie (as measured by the size of the characters that comprise the cookie non-terminal in the syntax description of the Set-Cookie header)
at most 20 cookies per unique host or domain name