Jakarta Commons HttpClient - cookies

I'm using the Jakarta Commons HttpClient package with my Java applet to send an "end session" HTTP request when the applet's destroy() method is called.

Can HttpClient access cookies set on the browser?

My application uses mod_python on the server side and creates a server-side cookie for the user's session. This method stores a client-side cookie in the browser's cookie cache containing the ID of the user's server session.

My "end session" handler requires that a valid session ID be given to help make sure that rouge users don't try to end other users' sessions.

However, when my applet sends the "end session" request, it does not send the session id cookie. Is it possible for my applet - using the HttpClient package - to find the session id cookie from the browser and send it with the request?

[843 byte] By [ironchicken83a] at [2007-11-26 19:10:39]
# 1
HTTPClient knows nothing about your web browser. It CAN send the correct cookie if you can tell it what cookie to send.However I doubt that the applet has any mechanism to do this.matfud
matfuda at 2007-7-9 21:06:53 > top of Java-index,Java Essentials,Java Programming...
# 2

You may be on the wrong track. Browsers are not the only applications that are allowed to use cookies. Your application can too. In particular your HttpClient can receive a cookie sent from the server and use it in future requests. Your program could even cache it and use it in future runs.

Just don't expect to share with some other application. Firefox doesn't try to swipe IE's cookies and you shouldn't either.

Edit: I see your code is running in an applet. So it's not completely unreasonable to expect that the applet might share cookies with the browser it's running in. Your question about whether HttpClient could do that misled me.

I don't do applets. But if I wanted to know if an applet could get a cookie from its browser environment, I would look for methods in the Applet class that did that.

Message was edited by:

Me, of course.

DrClapa at 2007-7-9 21:06:53 > top of Java-index,Java Essentials,Java Programming...