Sending cookies with OOSocks

This script is based on my friend’s script, but he doesn’t know what’s wrong, and I don’t know a lot about how sockets work.

http://iriz.pastebin.com/gDaDYa27

I can get a new cookie just fine with alan.AssignCookie(uniqueid, callback), but when I use that cookie in alan.SendQuestion(uniqueid, question, callback) like so:

[lua]socket:SendLine(Format(“GET %s&question=%s HTTP/1.1”, AlanURL(), URLEscape(question)))
socket:SendLine(“Host: www.a-i.com”)
socket:SendLine(Format(“Cookie: ASPSESSIONIDACRQSRQC=%s”, cookies[uniqueid]))
socket:SendLine("")[/lua]

It doesn’t set the cookie properly. Instead it gives me a new cookie that differs from the one I sent.

When I run the script it calls the example code at the bottom of the script, this is the output:


SET COOKIE TO: 	ONCFJJCBPEFPBCMPJEAEKBEM


COOKIE FOUND IN ANSWER BUT IT DOESN'T MATCH ANY OF THE LOCALLY STORED COOKIES

THE COOKIE FOUND WAS: PNCFJJCBDEBPCEPPDFMPHNJH

Here is the script I based it on:
http://danielga.bplaced.net/Uploads/chatbot_example.lua

And here is the old one I used using luasocket (which is now broken, so I wanted to remake it):
http://code.google.com/p/alanthefairy/source/browse/trunk/lua/entities/gmod_alan/sv_alan.lua

-snip-

Oh and ralle suggested that I should try and send it all in one go with socket:Send() and concatenate strings and add newlines. That didn’t work either.

I managed to receive a cookie (Set-Cookie) but it differs from the one I sent.

new paste: http://iriz.pastebin.com/gDaDYa27