in reply to cookie check

You can try to set a cookie, using the Set-Cookie header, then redirect to another page that checks for the cookie that you've just tried to set. That's the best way I can think of, right now.

So just set a cookie, then do a redirect (by sending the Location header, or by using CGI.pm's redirect method) to another page that checks for the cookie in $ENV{COOKIE} (or by using the cookie method of CGI.pm).