Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Dealing with session cookies

by rphlb (Initiate)
on Jun 21, 2004 at 18:23 UTC ( [id://368522]=perlquestion: print w/replies, xml ) Need Help??

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

I am writing a Perl app, that will "Log into" an WinNT web page, one of those ASP programs. It uses a session cookie, which of course, Perl 'Reads' as parsed data, I can put this cookie anywhere I like, that's not the issue, but I can't 'Send it back' to the WinNT server without getting an error. I'd like to get some examples of how some of you wizards have done this one. I tried using sockets and or WGET and got the same results no matter what. So "How do I do this?"

Thanks ahead of time.

Replies are listed 'Best First'.
Re: Dealing with session cookies
by arthas (Hermit) on Jun 21, 2004 at 18:34 UTC

    Hi!

    Could you post some more information on the error you get, and they way you followed to deal with cookies? Anyhow, you can easily do the job using LWP. Here's an example, which I took from lwpcook man page (it becomes available on you system when you install LWP):

    use LWP::UserAgent; use HTTP::Cookies; + $ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave => 1)); + # and then send requests just as you used to do $res = $ua->request(HTTP::Request->new(GET => "http://www.yahoo.no")); print $res->status_line, "\n";

    Basically, this code creates a cookie jar for you and handles all cookie things automagically. It should be what you are looking for. ;-)

    Michele.

      Sorry,
      I've been away dealing with an IBM mainframe and IBM tech support, talk about issues, wow.

      Anyway, thank you for your input. I will try this, I've never dealt with the LWP stuff before, cookies I have, but not in this manner before. I see that quite a lot of folks out there ask you guys about cookies a lot. Almost like a book could be written on just that, cookies and dealing with them. With Perl being TIMTOWDI, I would assume there is more than one way to do this, dealing with ASP and sesion cookies. BTW, U asked about the error message from ASP, here it is:
      "Microsoft VBScript runtime error '800a0005'
      Invalid procedure call or argument: 'Mid'
      /webdms/login.asp, line 440"

      I will check back with this a bit later this week. Thanks again for all of the help.

        Michele
        You also asked how I am doing the call to get the web page, been a lot going on around here today, I apologize for that.

        I've used a standard issue cgi GET, as in,
        "$result = GET $url"
        Within the $url variable is also the
        "?id=$id&password=$psw...."
        This gave me the error msg I showed a bit earlier. I "See" the cookie come through as parsed data, which I think I can use the LWP stuff to send it back, that appears to be what my troubles are, getting the cookie back to the ASP program.

        If there is more to do with this, please let me know, thanks again.

Re: Dealing with session cookies
by heroin_bob (Sexton) on Jun 21, 2004 at 22:11 UTC
    Is your app receiving login info from a form and then sending it to the ASP program, or are you just sending a known user/pass combo?

    If you're ever lost and need directions, ask the guy on the motorcycle.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://368522]
Approved by matija
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-26 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found