Data stored in cookies can be accessed via $COOKIE['name']. This is for reading. For writing to the cookie use [man]setcookie[/man]
A. When displaying message:
- check if the message id is in $COOKIE['read']
- if it is not there, append it to received cookie data and send back using setcookie
B. When displaying links, get $_COOKIE['read'] and check which id's are there.
I would store the id's as name: read, value: id1;id2;id3;...
Then the array of read id's can be obtained with
$read_id = explode(";",$_COOKIE['read']);
//check if id is in a table
if (in_array("id",$read_id)) echo 'class="read"';
else echo 'class="unread"';
When you want to add id to the array:
if (!in_array("id",$read_id)) setcookie("read",$_COOKIE['read'].";id",time()+$nr_of_seconds_to_store_information);