$ curl -I https://auth.example.com --cookie-jar ./cookie.txt --basic --user somedude 200 OK [...] Set-Cookie: session=mdkfUHAUnjdfj[...] path=/; expires=Sat, 15 Apr 2017 04:08:35 -0000; secure; HttpOnly [...] $ cat ./cookie.txt # Netscape HTTP Cookie File # https://curl.haxx.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. #HttpOnly_auth.example.com FALSE / TRUE 1492227302 session mdkfUHAUnjdfj[...] #### #!env perl use HTTP::Cookies::Netscape; my $cookies_file = defined($ARGV[0]) ? $ARGV[0] : exit ; my $Netscape_cookie_jar = HTTP::Cookies::Netscape->new( file => $cookies_file ); print $Netscape_cookie_jar->as_string;