1

Cookieを実行しようとして、Webサイトにログオンしています。私が理解していることから、IdCookieManagerをIdHTTPに割り当て、設定するだけで十分AllowCookies:=trueですよね?ログイン後、Cookieを正常に受信しましたが、さらにナビゲートしようとすると、Cookieが送信されません。

これが私が持っているコードです:

procedure TForm1.Login;
var data: TStringList;
begin
  data:=TStringList.Create;

  try
    IdHTTP.Get('http://navratdoreality.cz/'); // Here I receive Set-Cookie

    data.Add('ACTION=check_adult');
    data.Add('check=18plus');

    Memo1.text:=IdHTTP.Post('http://navratdoreality.cz/',data); // Here the 
     // request contains the cookie and I get a succesfully-logged page in 
     // response, no more set-cookie
  except
    ShowMessage('err');
  end;

  data.Free;
end;

procedure TForm1.Navigate;
var ms:TMemoryStream;
begin
  ms:=TMemoryStream.Create;
  try
    IdHTTP.Get('http://www.navratdoreality.cz/?p=view&id='+Edit1.Text, ms); 
    // the request doesn't contain any cookies, even though the cookie from 
    // logging is saved in IdCookieManager

    ms.Position:=0;
    Memo1.Lines.LoadFromStream(ms, TEncoding.UTF8);
  except
    ShowMessage('err');
  end;

  ms.Free;
end;

何が問題なのかわかりません。私のインディは10.5.8.0です。あなたがサイトを見るつもりなら、注意してください、それのいくつかはnsfwです。

ありがとう

4

1 に答える 1

0

Okay, this was a very stupid question. The problem was that the login part had http://navratdoreality.cz, whereas the next part had http://www.navratdoreality.cz. Both URLs displayed the same, but they were apparently different for the IdCookieManager, so that's why the cookie wasn't sent.

于 2012-07-16T08:41:58.753 に答える