title: Maintaining Session using HTTPClient on a Rails Application
body: <p>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. </p>
  
  <p>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:</p>
  
  <pre><code>        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");
  </code></pre>
  
  <p>Any suggestions would be great!</p>
  
  <p>slothishtype</p>