views:

78

answers:

1

hello all

I'm making some simple Delphi software using the IdHttp module in Indy. I want to access this page by using IdHttp's post function to open this webpage.

Firstly I have to log in, (at http://user.buddybuddy.co.kr/Login/Login.asp), so I logged in, but after I logged in to the webpage I can see another login page. But when I try to login (at http://user.buddybuddy.co.kr/usercheck/UserCheckPWExec.asp), I encountered an error message, "Illegal access."

If anyone can help me I would appreciate it!

        begin
      sl.Clear;
      sl.Add('ID=ph896011');
      sl.add('PWD=pk1089');
      sl.add('SECCHK=0');
      IdHTTP1.HandleRedirects := True;
      IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
      memo1.Text:=idhttp1.Post('http://user.buddybuddy.co.kr/Login/Login.asp',sl);

      if pos('top.location =',Memo1.Text)> 0 then

       begin
        application.ProcessMessages;
        sleep(1000);
        Memo1.Text:= '';
        sleep(300);
        sl2.Clear;
        sl2.Add('PASSWD=pk1089' );
        Memo2.Text := IdHTTP1.Post('http://user.buddybuddy.co.kr/usercheck/UserCheckPWExec.asp', sl2);


        sleep(300);
        Memo1.Text := '';
        //memo1.Text := IdHTTP1.Get('https://user.buddybuddy.co.kr/Login/Logout.asp');
        //Sleep(1000);
       end;
+1  A: 

The server almost certainly keeps track of whether you're logged in by returning a cookie with the response from the request for Login.asp. You need to send that cookie back with any subsequent requests. To keep track of cookies, create a TIdCookieManager object and assign it to your HTTP object's CookieManager property. The first request will store the response's cookies there, and the next request on that same HTTP object will send them back, indicating to the server that you have already logged in.

Rob Kennedy
Something to keep in mind if you are using Indy 10 is that TIdCookieManager and its support classes are currently undergoing major re-writes, and as such there is a 50-50 chance of whether the cookies will actually work correctly.
Remy Lebeau - TeamB
Thanks a lot , but im quite new to delphi maybe would you can show me some sample example ? if so much apprecaited! Thanks again!
paul