下面的实例演示了如何获取 cookies。
实例
#include<iostream>#include<vector> #include<string> #include<stdio.h> #include<stdlib.h>#include<cgicc/CgiDefs.h>#include<cgicc/Cgicc.h>#include<cgicc/HTTPHTMLHeader.h>#include<cgicc/HTMLClasses.h>usingnamespacestd;usingnamespacecgicc; intmain(){ Cgicccgi; const_cookie_iteratorcci; cout << "Content-type:text/html\r\n\r\n"; cout << "\n"; cout << "\n"; cout << "CGI 中的 Cookies\n"; cout << "\n"; cout << "\n"; cout << "\"0\" cellspacing = \"2\">"; // 获取环境变量 constCgiEnvironment& env = cgi.getEnvironment(); for(cci = env.getCookieList().begin(); cci != env.getCookieList().end(); ++cci) { cout << "\n"; } cout << "
" << cci->getName() << " | "; cout << cci->getValue(); cout << " |
<\n"; cout << "
\n"; cout << "\n"; cout << "\n"; return0;}