in reply to Cookie login (pseudocode)
Note that CGI::Session can do much of that work for you, for example session storage and expiration.