Log in to moodle with raw HTTP requests

I am trying to log into moodle with individual HTTP requests, and I am using PHP for this and Moodle version 2.8.8. I can sucessfully send username and password to http://domain/moodle/login/index.php and retrieve the MoodleSession cookie, but when i test a cookie with http://domain/moodle/login/index.php?testsession=user_id, i get an error that cookies are disabled in my browser. I have set the cookie in the POST header (Cookie: MoodleSession=session-cookie_id), but I still get an error. I get an error too if I try to send requests via Firefox' Edit and Resend option. What to do??