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

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on creating script that logs in to site under different names

Replies are listed 'Best First'.
Re: creating script that logs in to site under different names
by sulfericacid (Deacon) on Mar 21, 2006 at 18:50 UTC
    This is actually quite simple. Unlike keeping the users available for chatting, all you need to do is get them signed in. Therefor you don't need to store the cookies like you normally would enabling you to do multi-logins.
    use WWW::Mechanize; my $mech = WWW::Mechanize->new(); my $url = "url.here"; $mech->get( $url ); $mech->submit_form( form_number => 2, fields => { username => 'name', passwrd => 'pass', } ); my $mech2 = WWW::Mechanize->new(); $mech2->get( $url ); $mech2->submit_form( form_number => 2, fields => { username => 'name', passwrd => 'pass', } ); my $mech3 = WWW::Mechanize->new(); $mech3->get( $url ); $mech3->submit_form( form_number => 2, fields => { username => 'name', passwrd => 'pass', } ); print "done";
    The above code is tested but there are other things to think about, too. You might want to randomly pull a few usernames each time so different users are signed in after each login session. It'll make it look more realistic to people who are looking at account profiles seeing the last access/login time for each user.

    You could also add a flatfile database and use a logout script to randomly pull a name or two of your signed in users every X minutes, too.

    This is the basics, but think about making it perform a little more realistic.



    "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

    sulfericacid
Re: creating script that logs in to site under different names
by Corion (Patriarch) on Mar 21, 2006 at 18:26 UTC

    If this is your forum, simply insert the new users into the database directly - there is no need to go through the web interface.

    If this is not your forum, then don't do that.

      It is mine and I suppose I could manually add it to the ONLINE table but the thing is, I'll be running this as a cron job on my server so there's ALWAYS someone online in my list. If I added it to the database myself, I'd have to manually add it every 25 minutes since that's what the time out is.

      I can't increase the timeout because other users' names would appear in the list long after they are gone, too.

Re: creating script that logs in to site under different names
by jcoxen (Deacon) on Mar 21, 2006 at 18:53 UTC
    Your name isn't 'A.J.' is it?

    Jack

      LMBO, that's funny stuff.


      "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

      sulfericacid
        The thing that kills me is the timing. That's today's strip!

        Jack

Re: creating script that logs in to site under different names
by kwaping (Priest) on Mar 21, 2006 at 21:11 UTC
    Why not just hard-code some "logged-in users" into the site's templates? :)

    ---
    It's all fine and dandy until someone has to look at the code.