What you are looking for by the sound of it is sessions - That is, the ability to store basic information about a HTTP client for the duration of their visit to the web site, over the essentially stateless HTTP-CGI protocol. There are a number of existing frameworks which should make this job a lot easier for you - These include
CGI::Session,
CGI::MxScreen and
Apache::Session (my personal favourite).
I would recommend having a look at what these excellent modules can offer with regards to your basic data storage and sessional requirements before creating more work for yourself and re-inventing the wheel.