[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1626
  • Last Modified:

Indy Http cookies ?

I need some one to write me some example to use cookies with indy http control.

Example:
- send post request to site
- accept cookies from site
- make another post request and send cookie from first request

Thank you !
0
65zgtre45rr
Asked:
65zgtre45rr
  • 5
  • 4
1 Solution
 
2266180Commented:
check the 2 peristent connection examples from here:
http://www.ciuly.com/delphi/indy/
0
 
65zgtre45rrAuthor Commented:
It is not useful to me because it is using TIdCookieManager. I need example of code that uses TIdHTTP.AllowCookies and TIdHTTP.CookieManager for delphi 8
0
 
2266180Commented:
what type is TIdHTTP.CookieManager in delphi 8? isn't it of type TIdCookieManager? because if I am correct, delphi 8 would have indy 10 which I believe still has TIdCookieManager. of course it's been some time since I last worked with indy 10 (was too buggy at the time) and I am still on indy 9.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
65zgtre45rrAuthor Commented:
I have find how to set cookie

idHTTP1.CookieManager.AddCookie('test=bla', 'localhost');

Now i need example how to get cookies.
0
 
2266180Commented:
you did not answer my question. is idHTTP1.CookieManager of type TIdCookieManager or not? if not, what type is it? because I believe it is. in which case my examples apply maybe with some small modifications.
0
 
65zgtre45rrAuthor Commented:
I think that it is.
0
 
2266180Commented:
you can check for sure by moving the mouse over the CookieManager (for example where you wrote idHTTP1.CookieManager.AddCookie('test=bla', 'localhost'); and read the hint.

in any case it should be as I said in which case the schema (and possible the example) I wrote on my page to whcih I gave you the link applies:

get the page
save the cookies
set cookies (manualy upto indy 9 at least)  // this might not be nesessary for indy 10
do the login
get and update the cookies // this alos might not be needed on indy 10
from now on, always set cookies (point 3) just before geting/posting/heading/etc from that site // this again might not be needed on indy 10

have you tried doing the above?
0
 
65zgtre45rrAuthor Commented:
I thin i solved the problem, i only need to do:
IdHTTP1.CookieManager.CookieCollection.Count;

and cookies will be set in new request.
0
 
2266180Commented:
just reading that property made it send the cookies at new request? that is pretty weird. guess I'll have to install indy 10 sometime and check out the behaviour myself.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now