I don't think what your trying to do is possible. Cookies are sent by browsers and at that are only sent to the domain name listed as creator of the cookie, so how can you get one from a socket connection?
If you could get a cookie from a simple socket connection that would constitute a major security threat, consider being able to get usernames and passwords from unsuspecting users by copying all of their cookies through a backdoor socket.
So having said that, I think you may be confusing the terminology. Can you rephrase your question and try and be more specific about what you're trying to do?
A PHP/C-Client/PEAR solution for webmail