owenhhs007 has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I am stuck on the grab some information from a cookies use LWP & HTTP. I'd like to ask some help with my problem. I use the WireShark to grap some information as follows:
username=engineer&password=ARC%24eng%26123HTTP/1.0 200 OK Set-Cookie: sysauth=648493960F100A5A0297276EED3F9D15; path=/cgi-bin/lu +ci/;stok=7D13FC47E626011E8534793B2C7DF288 Content-Type: text/html Cache-Control: no-cache Expires: 0
I need to split the "sysauth=****" from above. I am not familiar with Perl&LWP. Codes as follows:
#!/usr/bin/perl use warnings; use strict; use LWP; use HTTP my $browser = LWP::UserAgent->new; $browser->agent('localbot'); $browser->credentials( 'http://192.168.1.1/cgi-bin/luci/engineer/advanced/diagnostics +/upgrade/:80', 'testing',#<- the $realm 'engineer' => '1234' ); my $cookie_jar = HTTP::Cookies->new( file => "/some/where/cookies.lwp", autosave => 1, ); $browser = LWP::UserAgent->new; $browser->cookie_jar( $cookie_jar );
Q1: Can I grab the information like above, how to modify this code? Q2:If not, how to implement this?

Replies are listed 'Best First'.
Re: How to get the cookie
by Corion (Patriarch) on Jan 13, 2010 at 16:33 UTC

    The easy way is to use WWW::Mechanize, which will handle extracting the cookies from a response and sending them with a request for you. Otherwise, you can do what WWW::Mechanize does, by using the ->extract method of HTTP::Cookies.