in reply to cookie retrieval problem

You can't set and retrieve a cookie in one request. By the time you send the cookie to the browser, the browser has already finished sending information to the server — it's not going to turn around and send the cookie right back. That's not how HTTP works.

Depending on your browser, you may have to set a domain and a path in the cookie as well.