Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi 2010的Indy10 cookies-未发送cookies_Delphi_Delphi 2010_Session Cookies_Indy10 - Fatal编程技术网

Delphi 2010的Indy10 cookies-未发送cookies

Delphi 2010的Indy10 cookies-未发送cookies,delphi,delphi-2010,session-cookies,indy10,Delphi,Delphi 2010,Session Cookies,Indy10,我在尝试使用Delphi 2010和Indy 10.5.8发送cookie时遇到问题。下面的代码显示了这些过程 用于执行初始登录和用户身份验证-验证序列号,然后验证用户登录,然后轮询任何 其他登录用户 第二步是再次登录并查询用户论坛数据库。第二步由于没有发送cookie而失败 请参阅随附的JPG了解发生的情况(“AllPosts”的内容)。该图显示了我对程序的诊断 在尝试访问论坛数据库时生成。论坛在我登录时返回cookie信息 在中,但Indy10 Put命令不会在后续调用中将Cookie发送回

我在尝试使用Delphi 2010和Indy 10.5.8发送cookie时遇到问题。下面的代码显示了这些过程

用于执行初始登录和用户身份验证-验证序列号,然后验证用户登录,然后轮询任何 其他登录用户

第二步是再次登录并查询用户论坛数据库。第二步由于没有发送cookie而失败

请参阅随附的JPG了解发生的情况(“AllPosts”的内容)。该图显示了我对程序的诊断 在尝试访问论坛数据库时生成。论坛在我登录时返回cookie信息 在中,但Indy10 Put命令不会在后续调用中将Cookie发送回论坛

以下是用于访问论坛的代码的例外。前4个过程与登录有关 大厅和最后2个用于访问论坛。在附加的JPG中,您可以看到 TransmitPost成功登录论坛并在响应中获取Cookie。随后对 TransmitPost接收到响应错误号46,表示缺少Cookie。这两个 通过下面的常规ViewForums进行呼叫

已在设计时设置cookie管理器

// ****************************************************************************
procedure TNetPlayForumForm.TransmitRequest(const ReturnCode: Boolean = True;
                                        const ShowResponse: Boolean = True);
var
  Response: String;
begin
  Response := IdHTTPForum.Get(IPAdd);

if ShowResponse then AllPosts.Lines.Add(Response)
else GoodMessage('Ready.');

if ReturnCode then ResponseInteger := ExtractNumber(Response, ResponseData)
else
begin        // No return code for some transmissions.
  ResponseInteger := 0;
  ResponseData := Response;
end;
// ****************************************************************************
procedure TNetPlayForumForm.QVerifySerial;
begin
  BusyMessage('Verifying the serial number: ' + SerialNumber);
  AllPosts.Lines.Add('Verifying the serial number: ' + SerialNumber);
  IPAdd := rsNetPlayForumServer + Format(rsVerifySerial, [SerialNumber]);
  TransmitRequest;
end;
// ****************************************************************************
procedure TNetPlayForumForm.QLoginUser;
begin
  BusyMessage('Logging in: ' + UserName + ' on port ' + MyPortNumber + '.');
  AllPosts.Lines.Add('Logging in: ' + UserName + ' on port ' + MyPortNumber +
                     '.');
  IPAdd := rsNetPlayForumServer +
           Format(rsLoginUser, [SerialNumber, UserName, Password, MyPortNumber]);
  TransmitRequest;
end;
// ****************************************************************************
procedure TNetPlayForumForm.QPollTheLobby;
begin
  BusyMessage('Polling the forum for players on-line.');
  IPAdd := rsNetPlayForumServer + Format(rsPollTheLobby, [SerialNumber]);
  AllPosts.Lines.Add('Polling the forum for players on-line.');
  AllPosts.Lines.Add('IP addresses for players on-line:');
  TransmitRequest(False);
end;
// ****************************************************************************
procedure TNetPlayForumForm.TransmitPost;
var
  Response: String;
  RawHeaders: TIdHeaderList;
  Indx: Integer;
  RawHeader: String;
  Nam: String;
  PostStream: TStream;
begin
  PostStream := TStringStream.Create('');
  Response := IdHTTPForum.Put(IPAdd, PostStream);
  PostStream.Free;
  RawHeaders := IdHTTPForum.Request.RawHeaders;

  for Indx := 0 to RawHeaders.Count - 1 do
  begin
    Nam := RawHeaders.Names[Indx];
    RawHeader := 'Request: ' + Nam + ' = ' + RawHeaders.Values[Nam];
    AllPosts.Lines.Add(RawHeader);
  end;

  AllPosts.Lines.Add(Response);
  ResponseInteger := ExtractNumber(Response, ResponseData);
  RawHeaders := IdHTTPForum.Response.RawHeaders;

  for Indx := 0 to RawHeaders.Count - 1 do
  begin
    Nam := RawHeaders.Names[Indx];
    RawHeader := 'Response: ' + Nam + ' = ' + RawHeaders.Values[Nam];
    AllPosts.Lines.Add(RawHeader);
  end;
end;
// ****************************************************************************
procedure TNetPlayForumForm.ViewForums;
// ****************************************************************************
// Forum elements: This, Parent, Forum, Topic.  There can be multiple topics.
// A forum element contains: ID, Status, Type, Name
//                           Poster, Description, Topics, Posts
//                           LastPostDate, LastPostUser, Views, Replies, URL.
// ****************************************************************************
begin
  IPAdd := rsNetPlayForumAccess +
           Format(rsLoginToForum, [SerialNumber, UserName, Password]);
  TransmitPost;
  IPAdd := rsNetPlayForumAccess + rsViewForums;
  TransmitPost;
end;
// ****************************************************************************
如果您能给我一些建议,告诉我如何在论坛的后续通话中插入cookie信息,以安抚论坛的看门人,我将不胜感激


cookie将于1970年1月1日过期,您是否尝试调试Indy源代码,以确定这是否是缺少响应cookie的原因?