Click here to Skip to main content
12,294,042 members (69,548 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
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:

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.

Thommy
Posted 20-Sep-12 3:37am
ThommyO315
Edited 20-Sep-12 3:40am
Wes Aday104.2K
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 20 Sep 2012
Copyright © CodeProject, 1999-2016
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