perl get session cookie -
is not work cookie
#!/usr/bin/perl -w use strict; use warnings; use lwp::useragent; use http::request::common qw(get); use http::cookies; $ua = lwp::useragent->new; # define user agent type $ua->agent('mozilla/4.0'); # cookies $ua->cookie_jar( http::cookies->new( file => 'mycookies.txt', autosave => 1 ) ); # request object $req = 'http://www.google.com'; # make request $res = $ua->request($req); # check response if ($res->is_success) { print $res->content; } else { print $res->status_line . "\n"; } exit 0;
when cookie ( firebug )
name value pref id=00349dffbc142a77:ff=0:ld=en:cr=2:tm=1311217451:lm=1311217451:s=qkw9g4vawl19me4g
mycookies.txt is
#lwp-cookies-1.0 set-cookie3: pref="id=00349dffbc142a77:ff=0:tm=1311217451:lm=1311217451:s=qkw9g4vawl19me4g"; path="/"; domain=.google.com; path_spec; expires="2013-07-20 03:04:11z"; version=0
but site when cookie
name value verify test guest_id 131099303870438180 phpsessid 7s99iq1qcamooidrop4iehcv32
nothing in mycookies.txt
how fix it.
thank you.
your first cookie domain cookie expiry in future. gets written cookie jar.
the second cookie session cookie, , expires when program closes. gets kept in memory, , not written jar.
Comments
Post a Comment