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

Hello, I have written a nice CGI script that gets data from an ASP page, processes it, and POSTs data to another ASP page. I used the recommended LWP::UserAgent methods for this. The problem is that the ASP pages on either side rely on the IIS SessionID. The SessionID gets changed when the Perl script is called. My theory is that the use of LWP::UserAgent triggers IIS to destroy the old session and create a new one. Is there any other way to POST data without using LWP? Is my theory even close to correct? Any help would be greatly appreciated.
  • Comment on HTTP POST the hard way or (IIS grrrrr..)

Replies are listed 'Best First'.
Re: HTTP POST the hard way or (IIS grrrrr..)
by simon.proctor (Vicar) on Aug 16, 2002 at 22:18 UTC
    Nine times out of ten the session is handled via a cookie. If I remember my ASP its just a lookup for the session object on the server where the real data is.

    As you haven't posted your code I'll have to assume that my assumption is true :P. That being the case, you'll need to modify your code to accept cookies and store them in a cookie jar.

    Take a look at the cookie reference in the lwp cookbook which should be part of your standard distribution for how to do this.

    HTH - if I'm off the mark, please post some of your code and I'll have another try :)

    Simon
Re: HTTP POST the hard way or (IIS grrrrr..)
by dws (Chancellor) on Aug 16, 2002 at 22:59 UTC
    If the session ID is coming back to you in a cookie (which you determine by telneting to port 80 of the web server, and issuing the HTTP request by hand), then you need to create a cookie jar and associate it with the UserAgent, so that any cookies that are returned from the first request will accompany your POST.

    See this script for an example.