Marking an entry as 'unread'

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Matt Phelps
Forum Commoner
Posts: 82
Joined: Fri Jun 14, 2002 2:05 pm

Marking an entry as 'unread'

Post by Matt Phelps »

I wonder if I can get some advice.

I've coded a sort of weblog type site that lists individual entries by timestamp. I'd like to mark each entry as read or unread for each user.

How can I capture that sort of data? I could have a new sql table listing every page view by user but that sounds very server intensive! Or I could add a cookie for each user with a string of entries id's that had been read by that user. But that string could get very very long!

How is this accomplished on bulletin boards??
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

This is just ideas to continue discussion...

If you store all 'read' threads in an array

Code: Select all

$array[] = '1';
$array[] = '5';
$array[] = '95';
...and then [php_man]serialize[/php_man]() that array, you get a string that you can abit easier with cookies (might want to lookup [php_man]base64_encode[/php_man]() also).

Meaning, by transforming the above array, you likely will shrink it for easier usage. Upon retrieval, you [php_man]base64_decode[/php_man]() and [php_man]unserialize[/php_man]() it, to get the original array.

You don't have to use arrays, I'm just mentioning it. Hope that helps.
Matt Phelps
Forum Commoner
Posts: 82
Joined: Fri Jun 14, 2002 2:05 pm

Post by Matt Phelps »

Hmm...food for thought definately. Would it work if the array was huge though? Say the user looked at several hundred pages?
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

that still isnt that huge. its just little ints, not too bad
Matt Phelps
Forum Commoner
Posts: 82
Joined: Fri Jun 14, 2002 2:05 pm

Post by Matt Phelps »

Small enough to go in a cookie?
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

if it was me, i wouldnt be too worried about it. But I've never worked with client side cookies....
Post Reply