Page 1 of 1

Marking an entry as 'unread'

Posted: Tue Mar 30, 2004 5:49 am
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??

Posted: Tue Mar 30, 2004 6:06 am
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.

Posted: Tue Mar 30, 2004 7:16 am
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?

Posted: Tue Mar 30, 2004 7:21 am
by magicrobotmonkey
that still isnt that huge. its just little ints, not too bad

Posted: Tue Mar 30, 2004 7:58 am
by Matt Phelps
Small enough to go in a cookie?

Posted: Tue Mar 30, 2004 8:18 am
by magicrobotmonkey
if it was me, i wouldnt be too worried about it. But I've never worked with client side cookies....