Changing a cookie value

"Derek Ealy" <[email protected]> Fri, 08 Nov 2002 10:01:38 -0800
Newsgroups gmane.comp.gcc.cgicc.general
Message-ID <[email protected]>
Hi,

I haven't been able to figure out how to change the value of a cookie in my 
environment.

When my cgi is executed there are already a couple of cookie values in the 
environment. In certain instances I need to change one of them. I have code 
that looks like this right now:

    const CgiEnvironment& env = cgi.getEnvironment();

    vector<HTTPCookie> cookies = env.getCookieList();
    vector<HTTPCookie>::iterator itr;
    HTTPCookie cookie;
    for (itr = cookies.begin(); itr != cookies.end(); itr++) {
      if (itr->getName() == CALLING_URL_COOKIE)
	cookie = *itr;
    } // end for (itr...
    cookie.setValue(strNewValue);
    cout << HTTPHTMLHeader().setCookie(cookie) << endl;

But it when it outputs the new header info there are now two calling URL 
cookies, one with the old value and one with the new one.

Is there a way for me to delete the original cookie from the environment, or 
preferably modify it?

Thanks, Derek



_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail