If you are using wireshark, you should be able to easily notice if your program is sending back the cookie or not. By the way, I'm pretty much certain the thing you do with parameters of the request is wrong. Did you check what params.toString() returns? Is it compliant with the encoding you are declaring? Does content-length match?