in reply to Setting a cookie

I would strongly recommend you use CGI.pm if you're able to.

Setting a cookie is then as simple as: $q->cookie(<cookie values here>).