I have an applet that talks with a Rails Application. I wish to maintain a user’s session so that the applet’s communication is recognized as part of a user’s browsing session. I use apache’s HTTPClient to send the request but the rails application does not recognize the request as part of the users session.
This is the code that I use to build the request, I pass in session_id variable and the HTTP_COOKIE variable as applet parameters:
HttpClient client = new HttpClient();
Cookie httpCookie = new Cookie("localhost", "HTTP_COOKIE", http_cookie, "/", null, false);
Cookie sessionID = new Cookie("localhost", "session_id", session_id, "/", null, false);
HttpState initialState = new HttpState();
initialState.addCookie(httpCookie);
initialState.addCookie(sessionID);
client.setState(initialState);
PostMethod post = new PostMethod("http://localhost:3001/vizs/add");
Any suggestions would be great!
slothishtype
I solved this with the following code:
The two problems were:
1) Not putting the port number in the url.
2) Specifying the wrong session id. In this example the application is called chatter so the session_id is _chatter_session. I add the session id to the applet as a parameter.