fish is correct, the CGI module is built for this sort of thing, and should be included as part of the core perl distribution.
The code you've displayed should be setting the cookie, have you checked the cookie value using browser tools to see what's in there?
Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)