adsense


Saturday, 28 November 2015

C++ LANGUAGE RETRIEVING COOKIES

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



C++ LANGUAGE RETRIEVING COOKIES




Retrieving Cookies 


It is easy to retrieve all the set cookies. Cookies are stored 
in CGI environment variable HTTP_COOKIE and they will have 
following form. 

key1=value1;key2=value2;key3=value3.... 
Here is an example of how to retrieve 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> 
 
using namespace std; 
using namespace cgicc; 
 
int main () 
{ 
   Cgicc cgi; 
   const_cookie_iterator cci; 
 
   cout << "Content-type:text/html\r\n\r\n"; 
   cout << "<html>\n"; 
   cout << "<head>\n"; 
   cout << "<title>Cookies in CGI</title>\n"; 
   cout << "</head>\n"; 
   cout << "<body>\n"; 
   cout << "<table border = \"0\" cellspacing = \"2\">"; 
    
   // get environment variables 
   const CgiEnvironment& env = cgi.getEnvironment(); 
 
   for( cci = env.getCookieList().begin(); 
        cci != env.getCookieList().end();  
        ++cci ) 
   { 
      cout << "<tr><td>" << cci->getName() << "</td><td>"; 
      cout << cci->getValue();                                  
      cout << "</td></tr>\n"; 
   } 
   cout << "</table><\n"; 
   
   cout << "<br/>\n"; 
   cout << "</body>\n"; 
   cout << "</html>\n"; 
    
   return 0; 
} 
Now, compile above program to produce getcookies.cgi, 
and try to get a list of all the cookies available at 
your computer: 

/cgi-bin/getcookies.cgi 

This will produce a list of all the four cookies set 
in previous section and all other cookies set in your computer: 

UserID XYZ  
Password XYZ123  
Domain www.onlionedu.blogspot.com  
Path /perl 


No comments: