Trouble with session ID and Drupal cookies when trying to establish a connection with Service Module and http-post I am trying to complete an http-post between my common lisp application and my Drupal Site running Services and a Rest server.  Currently I have my rest server set up to accept user login, and using Poster (Firefox plugin to create http requests) I am able to connect to my rest server.  Also, using Poster  if I am currently logged in I get a response "406 Not Acceptable: Already logged in as.." and if I am not logged in I get "200 OK" and when I go back to my browser I am logged in to my Drupal site.  

Now I have been trying to simulate this same behavior using an http-post from my lisp application and I have been having a lot of trouble.  For a long time I was always getting "200 OK" if I had correct username and password in the body of my post looking something like this: 

username=ender2012&amp;password=password&amp;form_id=user_login


but it would not actually login and if I was already logged in I would never receive the 406 response that I expected.  Finally I downloaded HttpFox which showed me the actual post that Poster was sending and I noticed that Poster was sending a Cookie header that looked like this

Cookie: Drupal.toolbar.collapsed=1; CAKEPHP=10e32669174a611c8919eeff471a2a1c; Drupal.tableDrag.showWeight=0; has_js=1; SESSdc0685ed01f285dab628a3700259e6bc=3qqK5XPaLRhEx7o4wAbIq5qK9qHEzRxz5qUnYZsaXG0


Now if I add a Cookie header to my lisp application's post with the Cookie I saw in http-post from Poster and I am logged in, I will get the 406.  So it seems that there is some sort of session information stored in this cookie that I will need to use for my lisp application but I am unsure about how this would all work inside my application.  Could anyone help me understand all of this?

Details:

• I am running Drupal 7

• I am using Services 3.0

• I am using a rest server with session authentication

• I am using application/x-www-form-urlencoded

• I am running this server on MAMP localhost currently
All of the cookie information is set and returned in the response header of the login call.

This might also be of some help which explains how to make authenticated calls via a remote client.
http://drupal.org/node/910598

Also note that if you use a Firefox plugin, it will be able to access the cookie set in Firefox. Thus if you use a different application that cookie will be different, so you will not be able to auth via your custom app and simultaneously see yourself as logged in in Firefox.