Your code above is correct, assuming that your cookie isn't timing out (i.e. isn't a session cookie). Under normal circumstances, session cookies are discarded immediately upon exit from your 'browser'. If you want to force holding onto the cookie, use ignore_discard
in your constructor:
my $cookie_jar = HTTP::Cookies->new(file => 'C:\path\to\cookies.dat',
ignore_discard => 1);
The flag is documented in HTTP::Cookies
, and read HTTP_cookie#Session_cookie
to learn more about the behavior.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.