I am using mechanize and logging into the facebook also save the cookiesand fetch the data from $page_url. but next time when I try to fetch $pageurl, it will not give me proper result and showed me as logged out.Please let me know how can I reuse the cookies file next time instead of logging in again and again

use strict; use warnings ; use WWW::Mechanize; use HTTP::Cookies; my $url = "http://www.facebook.com"; my $username = 'XXXXXXXX' ; my $password = 'XXXXXXXX' ; my $mech_request; my $data = login() ; my $page_url = "http://www.facebook.com/profile.php?id=100001726191116 +" ; my $author_data = fb_pages( $page_url ) ; sub login{ my $fname = "fbkCookies.dat" ; $cookie_jar = HTTP::Cookies->new( file=>$fname, autosave=>1, ignore_di +scard=>1 ) ; cookie_jar->save( $fname ); + $mech_request = WWW::Mechanize->new( autocheck => 0 ) ; $mech_request->cookie_jar( $cookie_jar ) ; + my $res = $mech_request->get( $url ) ; $mech_request->get( $url ) ; $mech_request->form_name( 'menubar_login' ) ; $mech_request->field( email => $username ) ; $mech_request->field( pass => $password ) ; $mech_request->click() ; my $contents = $mech_request->content() ; return $contents ; } sub fb_pages { my $url = shift ; my $res = $mech_request->get( $url ) ; $mech_request->get( $url ) ; my $data = $mech_request->content() ; return $data; }

In reply to How to reuse login info from cookies after logged first time in facebook and do the required search by sonal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.