Click here to Skip to main content
12,889,448 members (50,511 online)

Cookies in XE2 using TIdHTTP

ThommyO asked:

Open original thread
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.

Tags: C++


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

Advertise | Privacy | Mobile
Web01 | 2.8.170424.1 | Last Updated 26 Mar 2009
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