I would even try one of the recipees from mod_perl: Cooking Recipes, basically trying to get/set a cookie the hard way requires reading some Apache2:: docs
I would stick with a framework that abstracts away these low level details, Dancer/Catalyst/Mojolicious/CGI::Application...