The LWP::UserAgent::request function does redirection
but cookies get lost in that.
I believe that is a bug in LWP but I'm convinced
you did not actually intended to use the request function
since you do the redirection yourself so
I suppose change the 433 line from:
my $res = $self->ua->request($req);
to
my $res = $self->ua->simple_request($req);