delphi idhttp 存储cookies的问题
用idhttp.post 登陆账号以后 如果还想再post发帖的话 cookies如何存储和转移求代码示范

解决方案 »

  1.   

    我现在是自己从
    IDHTTP1.Response.RawHeaders.TEXT中 提取COOKIE然后要提交时 再添加 
    IDHTTP1.Request.CustomHeaders.Text := 'Cookie: '+ sCookie;
      

  2.   


    IDHTTP1.Response.RawHeaders.TEXT中 提取COOKIE中的cookies 就是  IDHTTP1.Request.CustomHeaders.Text := 'Cookie: '+ sCookie;  这里的scookie ?
    POST 提交的数据怎么写? 能不能具体一点
    就是idhttp post包的内容
      

  3.   

    post内容,比如登录  IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded';
      IdHTTP1.Request.CacheControl:='no-cache';  sPost:=TStringStream.Create('');
      try
        sPost.WriteString('user='+'username'+'&'+
                          'pwd='+'123456'
                          );//
        try
          IdHTTP1.Post('http://www.youname.com',sPost);
        except
        end;
      finally
        sPost.Free;
      end;
      

  4.   

    提取cookievar
    sCookie:string;
    i:Integer;
    begin
      sCookie:='';
      for i:=0 to IdHTTP1.Response.RawHeaders.Count-1 do
      begin
        if UpperCase(Copy(IdHTTP1.Response.RawHeaders[i],1,10))='SET-COOKIE' then
        begin
          sCookieTmp:=Trim(Copy(IdHTTP1.Response.RawHeaders[i],12,MAXINT));
          sCookieTmp:=Copy(sCookieTmp,1,Pos(';',sCookieTmp)-1);
          sCookie:=sCookie+sCookieTmp+'; ';
        end;
      end;
    end;再把取得的sCookie传给IdHTTP1  IdHTTP1.Request.CustomHeaders.Add('Cookie: '+sCookie);再比如发表评论IdHTTP1.Post....................就OK
      

  5.   


    回去再看 对于idhttp的cookie我也是遇到问题