The redirect has to go in the header, and after you've called
'header', you've already sent the header entirely. So you
need to send the cookie as part of the redirect. And you
can do that using the 'redirect' function/method:
print redirect(-cookie => $c);
If you have a CGI object, use
print $cgi_object->redirect(-cookie => $c);