Click here to Skip to main content
12,827,807 members (46,482 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++
I cannot access cookies in TIdHTTP!
The client code is like this:
This property is set:
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
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:

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:
"\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.

Posted 20-Sep-12 4:37am
Updated 20-Sep-12 4:40am
Wes Aday104.2K
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)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170326.1 | Last Updated 20 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100