Sunday, May 30, 2004

Old, improved feature...

The new comment count code has been rewritten once again. I said I'd fixed it for Mozilla and I had. Sort of. I've been using Firefox more and more and noticed that when there had been a lot of comments to read ones I'd already read would appear unread after I read few more.

It turns out this is due to a limit to the number cookies you can dump on a machine from 1 address. IE suffered the same thing but it seemed to have a much higher number of cookies allowed so it took longer to see the effect of it. I thought this might have been a problem when I first wrote the new comment code so I had a half idea how I was going to do it anyway.

So I've dumped Bill Dortch's cookie library and got hold of Stephen Chapman's cookie library from Felgall. This one has built in array handling so I'm storing all the comment counts in one array which gets stored in 1 cookie. I also now set the cookie when you enter the page the comments are on. Previously it was in the 'onclick' property of the link to the page. This meant it was only set when you clicked the link from the main or archive pages. If you came in through the 'Previous Posts' link or from a search then the cookie wasn't being set. That's sorted now so new comment counts should reflect whatever you have read regardless of how you got there.

The next problem I can see is when the cookie gets too large and you can't write any more info to it. I think it has a 4Kb limit. That's plenty of comment counts though so we shouldn't hit that too fast. I know how I am going to do it but I'll worry about that if/when we hit the limit.

Right I know most of you fell asleep 3 paragraphs ago but this bit is important. If the new comment count isn't working delete your cookies for this site - you may have reached your limit and the new fangled one can't be created. It may also be that you are caching an old version of the page without the new code (this happened quite a bit during debugging) so you may want to try the New Links patented Anti Green Screen Key™

No comments: