I recommend you check out CGI::Application and CGI::Application::Plugin::Session. They work great with HTML::Template and will give you to tools you need to properly structure your application and provide user sessions.
-sam
Comment on Re: HTML::Template and authenticated sessions