2014-10-09 106 views

回答

0

这里是我:“我的设置曲奇”

CInternetSession session; 
CHttpConnection* connection=0; 
try { 
    INTERNET_PORT port = 80; 
    CString server("mydomain.com"); 
    CString path("/cookie-test.cgi"); 
    CString cookieUrl("http://"+server+path); 
    BOOL res = session.SetCookie((LPCSTR)cookieUrl,0,"my_cookie=Set My Cookie!"); 
    if(res == FALSE) { 
    DWORD error GetLastError(); 
    // code to format error message 
    } 
    connection = session.GetHttpConnection(server,port); 
    file = connection->OpenRequest(
    CHttpConnection::HTTP_VERB_GET, //Action verb 
    path //Object to perform action on 
    ,0,1,0,0,INTERNET_FLAG_*); // pick your flags 
    file->SendRequest(); 
    // Check status, read response, process 
} 
catch(CInternetException *e) { 
    // report error 
} 
connection->Close(); 
file->Close(); 
delete file; 
delete connection; 

我的饼干test.cgi看到my_cookie具有的价值