如何显示论坛帖子的未读/已读状态,例如 vbulletin、phpbb 等?

发布于 2024-08-18 10:16:40 字数 289 浏览 8 评论 0原文

这是一个价值百万美元的问题,我在这里和其他 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 技术交流群。

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

发布评论

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

评论(3

¢好甜 2024-08-25 10:16:40

更重要的是,cookie 规范规定浏览器每个域只需要接受 20 个 cookie。 Firefox 将此限制增加到 50 个,Opera 增加到 30 个,但 IE6 和 IE7 强制每个域 20 个 cookie 的限制。任何超出此限制的 cookie 都会淘汰旧的 cookie,或者被浏览器忽略/拒绝。

摘自此作者的帖子

我相信对于未读/已读的人论坛帖子的状态应通过数据库来完成。我无法在网上找到示例,但我已阅读 "PHP 和 MySQL Web 开发 (4th Edition)” 并且他们有一个专门用于开发您自己的论坛页面的部分。他们提供示例代码并解释启动过程。

More importantly though, the cookie specification says that browsers need only accept 20 cookies per domain. This limit is increased to 50 by Firefox, and to 30 by Opera, but IE6 and IE7 enforce the limit of 20 cookie per domain. Any cookies beyond this limit will either knock out an older cookie or be ignored/rejected by the browser.

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.

夏日落 2024-08-25 10:16:40

我不认为他们使用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.

心凉怎暖 2024-08-25 10:16:40

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

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