If the session ID is coming back to you in a cookie (which you determine by telneting to port 80 of the web server, and issuing the HTTP request by hand), then you need to create a cookie jar and associate it with the UserAgent, so that any cookies that are returned from the first request will accompany your POST.
See this script for an example.