hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergio Berna <sbe...@extendnow.com>
Subject RE: How to use session cookie across connections
Date Tue, 25 Mar 2003 16:53:37 GMT
It should work if you place the following line on your httpclient

		HttpState initialState = new HttpState();
        // Initial set of cookies can be retrieved from persistent storage
        // re-created, using a persistence mechanism of choice,
        // A different cookie management spec can be selected
        // when desired

//      initialState.setCookiePolicy(CookiePolicy.NETSCAPE_DRAFT);
        // Netscape Cookie Draft spec is provided for completeness
        // You would hardly want to use this spec in real life situations
//      initialState.setCookiePolicy(CookiePolicy.COMPATIBILITY);
        // Compatibility policy is provided in order to mimic cookie
        // management of popular web browsers that is in some areas 
        // not 100% standards compliant

        // Get HTTP client instance

        //create a singular HttpClient object
        client = new HttpClient(/*new

        //establish a connection within 20 seconds

And then using the same httpclient object for all the calls, the session is
maintained at the httpclient object.

I would not use MultiThreadedHttpConnectionManager since it is giving me
problems at the current version stopping all connections after 1 minute or

Hope this helps.

-----Mensaje original-----
De: vijay kumar [mailto:gm_vijaykumar@hotmail.com]
Enviado el: martes, 25 de marzo de 2003 17:47
Para: commons-httpclient-dev@jakarta.apache.org
Asunto: Re: How to use session cookie across connections


Thanks for ur response.

Actually my problem is I got a class file where httpclient is initialized 
and used. During login I am getting a session cookie and able to access 

When I try to call the class again to make another requests my cookie is 
gone. As I am new to httpclient I am not sure whats happening. Is there any 
way to store the cookie which I can use for subsequent connections.

thanks a lot

>From: Oleg Kalnichevski <o.kalnichevski@dplanet.ch>
>Reply-To: "Commons HttpClient Project" 
>To: Commons HttpClient Project <commons-httpclient-dev@jakarta.apache.org>
>Subject: Re: How to use session cookie across connections
>Date: 25 Mar 2003 17:28:22 +0100
>HttpClient class does preserve HTTP state information across
>connections. You may want to consult the documentation on HttpState
>class for more details
>This sample may also be of some help
>On Tue, 2003-03-25 at 13:25, vijay kumar wrote:
> > Hi
> >
> > How to handle a session cookie across connections. In my program I will 
> > getting a seesion cookie during initial stage of login and I want to use

> > same session cookie for my other requests.
> >
> > Any samples available???
> >
> > Thanks,
> > Vijay
> >
> > _________________________________________________________________
> > Cricket - World Cup 2003 
> > News, Views and Match Reports.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: 
> > For additional commands, e-mail: 
> >
>To unsubscribe, e-mail: 
>For additional commands, e-mail: 

Get ball by ball action on your desktop. 
http://server1.msn.co.in/msnspecials/cricketdownload/contest.asp Get Hutch 
MSN Cricketer

To unsubscribe, e-mail:
For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message