Re: Changing a cookie value
"Alexander J. Oss" <[email protected]> Sat, 9 Nov 2002 12:04:22 -0500
| Newsgroups | gmane.comp.gcc.cgicc.general |
|---|---|
| Message-ID | <005101c28812$0e252760$0101a8c0@puter> |
I'm pretty sure that once you set a cookie, it's not your environment in which it's set--it's your client's browser's environment. So unless you wait for the cookie to expire in the browser, the browser's required to continue to return it to your web server. Perhaps instead of changing the cookie value itself, you should use a cookie with a value that identifies information you keep on the web server (e.g. on a database), and when you need to change information, you change the database. I believe this is a very common approach. Hope that helps! ----- Original Message ----- From: "Derek Ealy" <[email protected]> To: <[email protected]> Sent: Friday, November 08, 2002 1:01 PM Subject: [help-cgicc] Changing a cookie value 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 _______________________________________________ help-cgicc mailing list [email protected] http://mail.gnu.org/mailman/listinfo/help-cgicc