If I follow what you are saying, the cookies are working
as advertised. Here's my rephrased walk-through of
what you seem to be describing.
- In a CGI script activated by a "Save" button in a form
you set a cookie by printing it out in
the header.
- In that same script you then test for the cookie.
- But at that point the cookie is not there.
- Later (another page load) the cookie is there.
The current CGI script gets its cookie values from the
remote client browser at the
script start-up. The cookie value you set is still in the
stream of output to the user's browser when you print it
and in all subsequent parts of the current script.
The cookie is not available (to be checked or used)
until you get a response back from the client browser
which has received the cookie and then sends it back
to a script at your end for use (either
the same script or a different one).
Does this help?