in reply to automated cookies

WWW::Mechanize does this already. Until you leave your script. If you want permanent cookies stored on disk, use a cookie object of your choice.
my $mech = WWW::Mechanize->new( cookie_jar => HTTP::Cookies->new( file => '/tmp/my_cookies.dat', autosave => 1, ) );
Boris

Replies are listed 'Best First'.
Re^2: automated cookies
by Anonymous Monk on Jan 31, 2005 at 18:24 UTC
    Thank you.

    I have run into a problem now with a checkbox. I'm not sure what I'm supposed to do to make it put a check in the checkbox, otherwise I don't think their server will give me remember me.

    Their code is

    ><form method="post" action="login.php?sid=c51 +4c45f8ced1eae9f9eced24365bf48"> <table border="0" cellpadding="0" cellspacing="1" width="100%"> <tr> <td align="center"><span class="gensmall"> <input type="hidden" name="redirect" value="" /> Username:<br /> <input class="post" type="text" name="username" size="15" /> <br /> Password:<br /> <input class="post" type="password" name="password" size="15" /> <br /> </span> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td><input class="text" type="checkbox" name="autologin" /></td> <td class="gensmall">&nbsp;Remember me</td> </tr> </table>
    I got all of it working so far (I believe-- no errors anyway) but I get an error "Illegal value 'check' for field 'autologin' at ...".

    Do you know how I can automate this? My code is below.

    #!/usr/bin/perl use warnings; use strict; my $username = "test"; my $password = "test"; use CGI::Carp qw(fatalsToBrowser); use WWW::Mechanize; use CGI qw/:standard/; my $browser = WWW::Mechanize->new(); $browser->get("http://www.mwjz.com/phpbb/portal.php"); $browser->form(1); $browser->field("username", $username); $browser->field("redirect", ""); $browser->field("autologin", "check"); $browser->field("password", $password); $browser->click(); print header; print $browser->content();
      If you search the documentation for checkbox, you'll come accross a method called tick(). Can you guess what its used for (hint: you don't have to guess, you can read about it)?

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

      Don't know about php, but in an html form,
      checked="true"
      goes in the input class:
      <td><input class="text" type="checkbox" name="autologin" /></td>
      to preselect a button. suspect you could add a select="true" in your output?
Re^2: automated cookies
by Anonymous Monk on Jan 31, 2005 at 23:23 UTC
    Say we used that code of yours to save a cookie to /home/user/public_html/script/data.dat . How would we get the other Mechanize scripts to read this cookie and use it? Or does this both save and use it?