How can I accept cookies in a python script?
It's unclear whether you want a client-side or a server-side solution.
For client-side, cookielib will work fine. This answer and a few web tutorials offer more in-depth explanations.
If this is a server-side problem, you should be using a framework that takes care of all the boilerplate. I really like how CherryPy and web.py handle them, but the API is pretty simple in any library.