Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ASP
Re: Capture sessionID in browser from perl script
 

Index | Next | Previous | View Flat


tchatzi at arx

Apr 1, 2009, 2:50 AM


Views: 12063
Permalink
Re: Capture sessionID in browser from perl script [In reply to]

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 [at] perl
> For additional commands, e-mail: asp-help [at] perl
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe [at] perl
For additional commands, e-mail: asp-help [at] perl

Subject User Time
Capture sessionID in browser from perl script sudarshan12s at gmail Apr 1, 2009, 2:24 AM
    Re: Capture sessionID in browser from perl script tchatzi at arx Apr 1, 2009, 2:50 AM
        Re: Capture sessionID in browser from perl script sudarshan12s at gmail Apr 3, 2009, 7:05 AM
    Re: Capture sessionID in browser from perl script tchatzi at arx Apr 3, 2009, 7:25 AM
        Re: Capture sessionID in browser from perl script sudarshan12s at gmail Apr 8, 2009, 10:23 PM
    Re: Capture sessionID in browser from perl script tchatzi at arx Apr 9, 2009, 2:36 AM
        Re: Capture sessionID in browser from perl script laki.sreekanth at gmail Jun 18, 2009, 11:34 PM
        Re: Capture sessionID in browser from perl script laki.sreekanth at gmail Jun 18, 2009, 11:40 PM
            Re: Capture sessionID in browser from perl script sudarshan12s at gmail Jun 18, 2009, 11:54 PM
    Re: Capture sessionID in browser from perl script laki.sreekanth at gmail Jun 19, 2009, 4:33 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.