我想用cookie实现记录用户最近浏览过的10件帖子,比如规定cookie的name是TOPIC,value是帖子的id,title之类的。
因为cookie会覆盖以前相同name的值,所以我想在name后加入index区分,例如TOPIC1,TOPIC2……,如果有相同的帖子,则他们的VALUE值也相同,只保留最新的一个。超过10件就把最老的那个删掉,始终保持不超过10件。
请问如何用java实现
因为cookie会覆盖以前相同name的值,所以我想在name后加入index区分,例如TOPIC1,TOPIC2……,如果有相同的帖子,则他们的VALUE值也相同,只保留最新的一个。超过10件就把最老的那个删掉,始终保持不超过10件。
请问如何用java实现
get this topic;
get Cookie,if null create Cookie and set Topic1;
if(not null) split cookie into topics[],every index++(if index==10,drop it),topics[0]=this topic;Server Sends the Coolie to Browser.