flag is "UserName=", the string is searched in document.cookie, if it is not found, the page asks the user to enter a name, once it is entered, the name is saved in the cookie in the format of "UserName=whatever;expired=Fri, 10 Oct 2001 10:24:02 UTC".if the flag is found, the name is retrieved from the document.cookie by extracting the string between "=" and ";"
date.toGMTString() returns the date in GMT time, like
Fri, 10 Oct 2001 10:24:02 UTC