Sample JSP code:
String guid = NULL;/** read cookie */cookie [] cookies = request. getcookies (); If (cookies! = NULL) {for (INT I = 0; I if (C. getname (). specified signorecase ("guid") {system. out. println ("Find Cookie guid:" + C. getvalue (); guid = C. getvalue () ;}}/** if no guid cookie is found, generate a new guid and write the cookie */If (guid = NULL) {randomguid = new randomguid (); guid = randomguid. tostring (); cookie guidcookie = new cookie ("guid", guid); guidcookie. setmaxage (60*60*24*365); guidcookie. setdomain (" .Domain.com "); response. addcookie (guidcookie); system. out. println ("not find Cookie guid and set guid COOKIE:" + guid);} string username = request. getparameter ("username"); system. out. println ("request Username:" + username); If (username! = NULL) {system. out. println ("memcache set username [" + guid + "," + username + "]"); memcachedutil. put (guid, username);} username = (string) memcachedutil. get (guid); system. out. println ("memcache Username:" + username );