Loading ...
Sorry, an error occurred while loading the content.

2257Re: Capture sessionID in browser from perl script

Expand Messages
  • Thanos Chatziathanassiou
    Apr 1, 2009
    • 0 Attachment
      O/H Sudarshan Soma έγραψε:
      > Hi All,
      > I have a requirement to test webserver using perl scripts. The
      > webserver creates a sessionId after successfull authentication. Hence
      > for futher requests to the webserver, i need to send the sessionId
      > which is set in the browser/client . Can anyone please let me know how
      > can i do this.
      >
      > Myperl script is something like this:
      >
      > $requestString = "http://x.y.x.w"
      > $request = HTTP::Request->new(GET => $requestString);
      > $request->authorization_basic($userid, $passwd);
      > $request->push_header(Cookie => "SESSIONID=?????; path=/;"); ------>
      > capture session id from browser
      >
      rather:
      ---8<---
      use HTTP::Cookies;
      use HTTP::Request::Common;
      use LWP::UserAgent;

      $ua = LWP::UserAgent->new;
      $requestString = "http://x.y.x.w";
      $ua->cookie_jar(HTTP::Cookies->new);
      $result = $ua->request(HTTP::Request::Common::GET $requestString));
      $ua->cookie_jar->extract_cookies($res);
      #session id is now in the cookie jar. ``perldoc HTTP::Cookies''
      #to read it
      $anotherURI = "http://x.y.x.w/whatever";
      $requestObject = HTTP::Request::Common::GET $anotherURI;
      #automatically add the cookies (including the session-id) to this request..
      $ua->cookie_jar->add_cookie_header($requestObject);
      $result = $ua->request($requestObject);

      ---8<---

      >
      >
      > Best Regards,
      > Pavan
      >
      > ---------------------------------------------------------------------
      > To unsubscribe, e-mail: asp-unsubscribe@...
      > For additional commands, e-mail: asp-help@...
      >
      >


      ---------------------------------------------------------------------
      To unsubscribe, e-mail: asp-unsubscribe@...
      For additional commands, e-mail: asp-help@...
    • Show all 10 messages in this topic