in reply to Trouble with cookies

Here are a couple suggestions for cleaning up that code:

This should help make this a wee bit easier to handle. And thus easier for others to help with. Also, try to firm up what your question is, if possible. Especially with CGI scripting - it's harder for others to reproduce than other types of programs that we can take the source and run easily.