🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #1457

TIdCookieManager and threads

#1457
From: Bill D. Pirkle
Date: Mon, 20 Dec 2004 22:15
40 lines
2820 bytes
Hi all,

I'm writing an app that communicates with a variety of Web sites.  I
create the TIdHttp objects dynamically, each with its own thread.  So
far so good, that all works.  (I Googled and found some very nice
example code posted by Remy that helped a ton!)

Now I need to use cookies with some of these sites.  I know I need to
attach a TIdCookieManager to each TIdHttp object (and make sure that
AllowCookies is true).  My question is:  should I dynamically create a
separate cookie manager for each thread?  Or should I use one master
cookie manager that all the threads share?  If they share, are there
any simultaneous access worries that I need to sort out?

The advantage of sharing would seem to be that if I need to carry on
an extended conversation with a particular server, the shared cookie
manager just magically handles everything.  So (for example) I might
need to download and display info, wait for a user response, and then
do more communications with the Web server.  The Web server should see
this as the same user session.  With a shared cookie manager, my hope
is that everything would be okay, even if I use different thread (and
therefore different TIdHttp) objects for the different phases of the
conversation.  Whereas if each TIdHttp object needs its own cookie
manager, I need to essentially build my own session management layer
to handle all the threads and other objects.  But if sharing
introduces a bunch of threading headaches, that may be the only way to
go. 

Sorry if this is a dumb question.  I'm still pretty new to Indy.  I
did Google and check the Indy in Depth book before posting, but didn't
find an answer.

Oh, I'm using Indy 9.0.17 and BCB6.

Bill D. Pirkle

P.S.  Does anyone else have trouble with the Indy newsgroups?  I can
barely get any messages to download without timeouts, but I have no
problems accessing the Borland groups from the same computer.  I'm
using FreeAgent as a newsreader.
Technical Details
Message-ID: <41c74be0.158720888@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!tiscali!newsfeed1.ip.tiscali.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,659a1bc0f4fd10aa,start
X-Google-Attributes: gidfeeec,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: mbpirkle@NOSPAM.att.net (Bill D. Pirkle)
Newsgroups: borland.public.cppbuilder.internet.web
Subject: TIdCookieManager and threads
Date: Mon, 20 Dec 2004 22:15:39 GMT
Message-ID: <41c74be0.158720888@newsgroups.borland.com>
X-Newsreader: Forte Free Agent 1.21/32.243
NNTP-Posting-Host: 67.76.63.164
X-Trace: newsgroups.borland.com 1103580939 67.76.63.164 (20 Dec 2004 14:15:39 -0800)
Lines: 41
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!tiscali!newsfeed1.ip.tiscali.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail