🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #1692

Re: TIdHTTP and Cookie (newby question)

#1692
From: Remy Lebeau (TeamB)
Date: Wed, 22 Nov 2006 17:54
70 lines
3301 bytes
"Richard Kavanagh" <dd.foldhill@google-ignore-mail.com> wrote in message
news:45642bbb$1@newsgroups.borland.com...

> The cookie is stored in IE's cookie directory and looks like this:-

Indy has no concept of IE's cookies (or any other browser's cookies, for
that matter).  You have to parse the cookie file yourself and then add it to
the CookieManager manually.

> Going from back to front, I assume the star is some terminating symbol

Yes.

> the previous four numbers are FILETIME numbers indicating I know what not.

From back to front, they are creation time high/low DWORDs and expire time
high/low DWORDs.  More specifically, they are Win32 API FILETIME values.

> Not sure what 1536 stands for.

Flags that control the cookie's behavior.

> The first two probably mean authority and some over-complicated password

They are the cookie's name and value.

> followed by the domain.

It is the domain and path that the cookie is valid for.

> Looking at past correspondence on the same or similar subjects all they
> say is that the CookieManager does it all for you

Correct.

> there is no CookieManager.

Yes, there is.  TIdHTTP has a CookieManager property of type
TIdCookieManager.  Such a component exists on the Component Palette.  If you
do not provide your own CookieManager object to that property, then a
default one is created internally when TIdHTTP sends a request.

> How do I instantiate one and more importantly initialize it with the above
cookie?

Indy's cookie support requires the cookie text to be formatted according to
how they are transmitted over HTTP, not how they are stored in files.
Cookie storage is a browser-specific operation.  Only the HTTP format is
standardized.  As such, you will have to load the cookie data from file and
re-format into a text value that Indy can consume properly.  For example:

    ULONG ulFlags = 1536;

    TIdCookieRFC2109 *Cookie =
IdHTTP1->CookieManager->CookieCollection->Add();

    Cookie->CookieName = "auth";
    Cookie->Value = "7e5a7cec0769ed530cad95244bb62b44";
    Cookie->Domain = "einstein.phys.uwm.edu";
    Cookie->Path = "/";
    Cookie->Secure = (ulFlags & 0x0001);

Refer to the following page for more details:

    HTTP::Cookies support for Microsoft Internet Explorer
    http://www.geocities.com/typopl/msieinfo.htm


Gambit
Technical Details
Message-ID: <45648f67@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <45642bbb$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,68afa507f0d6b215
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <45642bbb$1@newsgroups.borland.com>
Subject: Re: TIdHTTP and Cookie (newby question)
Date: Wed, 22 Nov 2006 09:54:17 -0800
Lines: 72
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 69.169.4.232
Message-ID: <45648f67@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1164218215 69.169.4.232 (22 Nov 2006 09:56:55 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail