Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I cannot access cookies in TIdHTTP!
The client code is like this:
This property is set:
C++
IdHTTP1->AllowCookies = true ;

Count = IdHTTP1->CookieManager->CookieCollection->Count ;
for( int x = 0; x < Count; x++ )
{
Str = IdHTTP1->CookieManager->CookieCollection->Cookies[x]->CookieName ;
Str2 = IdHTTP1->CookieManager->CookieCollection->Cookies[x]->CookieText ;
}


The problem is that
C++
IdHTTP1->CookieManager->CookieCollection->Count
is zero.
I know that the Server side works Ok because when I request the same page in the browser I can display the value of the cookie.

-------------------------------------------------
the server side code:

C++
TDateTime	Date ;
Date = Date.CurrentDateTime() ;
Date++ ;
TCookie *pNewCookie = Response->Cookies->Add() ;
pNewCookie->Expires = Date ;
pNewCookie->Secure = false ;
pNewCookie->Name = "cookiename" ;
pNewCookie->Value = "cookieValue" ;

------
when I return this line to the browser:
C++
"\r\nCookieFields:" + Request->CookieFields->Text ;
the cookie and its value are there on the second round trip.


If anyone has any ideas, it will be much appreciated.

Thommy
Posted
Updated 20-Sep-12 3:40am
v2
Comments
Mohibur Rashid 20-Sep-12 20:58pm    
I dont know about TIdHTTP. Your code does not says that cookies are available. try installing "Live HTTP" for firefox and then read the whatever header is sent by your browser and then you might get some idea.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900