Autor Beitrag
huhn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 272
Erhaltene Danke: 1

WIN XP
D7Pers
BeitragVerfasst: Do 12.05.05 20:39 
Hi leute!
ich will ein programm schreiben das sich auf einer seite einloggt. diese seite besteht aus php-scripts und benützt daher sessionids cookies. ich möchte nun wenn ich mich eingeloggt habe auf jede andere seite gehen können ohne das immer kommt "sie sind ausgeloogt", deshalb muss(soviel ich langsam schon mitbekommen) jedesmal mich authentifizieren mit der vom server gegeben id, dow wie mach ich das???
ich hab schon folgendes probiert(ich benütze den cookiemanager):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure Tform1.Button4Click(Sender: TObject);
var
  SL: TStringList;
begin
  memo1.Clear;
  SL := TStringList.Create;
  try
    SL.Add(IdCookieManager1.CookieCollection.Items[0].ClientCookie);
    memo1.Lines.Text:=http.post('http://www.irgendwas.de/building1.php',SL);
  finally
    SL.Free;
  end;
end;

dies hat leider nicht funktioniert. muss ich des irgendwo anders machen oder stimmt des was ich gemacht habe und der fehler liegt wo anders?
Ach nicht das ich es vergesse, ich bekomme auch immer einen Wert bei dem:
IdCookieManager1.CookieCollection.Items[0].ClientCookie--->so was ungefähr:"jsid=23nj259539581tw"
ich danke euch schon mal im vorraus.
mfg huhn

_________________
Quod Erat Demonstrandum-Was zu beweisen war! *THX to Chrissivo!*
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Fr 13.05.05 13:28 
der cookiemanager sendet automatisch die cookies bei jedem request mit. da musste dich garnicht drum kümmern.

_________________
In the beginning was the word.
And the word was content-type: text/plain.
huhn Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 272
Erhaltene Danke: 1

WIN XP
D7Pers
BeitragVerfasst: Sa 14.05.05 11:37 
jo hab des jetzt au herausgefunden*g* :lol:
naja ich glaub des liegt irgendwie an dem grafikcode das ich mich nicht einloggen kann.
hier mal javaauszug:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
<form action="login.php" method="post">
<input type="hidden" name="step" value="2">
<table border=0 cellspacing=1 cellpadding=4 align="center" bgcolor="#000000" width="400">
  <tr>
    <td align="center" colspan=2 class="tblhead">Login</td>
  </tr>
  <tr>
    <td bgcolor="#cdcdcd" width="150" class="tbl">Benutzername:</td>
    <td bgcolor="#dddddd" class="tbl"><input type="text" name="username" value="" tabindex=1></td>
  </tr>
  <tr>
    <td bgcolor="#cdcdcd" class="tbl">Passwort:</td>
    <td bgcolor="#dddddd" class="tbl"><input type="password" name="password" value="" tabindex=2> <a href="lostpw.php">vergessen?</a></td>
  </tr>
  <tr>
    <td bgcolor="#cdcdcd" class="tbl">Grafikcode:</td>
    <td bgcolor="#dddddd" class="tbl"><input type="text" name="gcode" tabindex=3> (unten)</td>
  </tr>
  <tr>
    <td align="center" colspan=2 class="tblhead"><input type="submit" value="Einloggen" tabindex=4></td>
  </tr>
</table>
<br><br>
<center><img src="grafikcode.php" border=0><br>
<font size=3><b>Mögliche Zeichen: (0, 2, 4, 6, 8, a, c, u, x, n)</b></font></center>
</form>

ich versuch mich damit einzuloggen:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
procedure TForm1.FormCreate(Sender: TObject);
var   bild:TPNGObject;
      s:TFilestream;
      bmp:TBitmap;
begin
//exedir
  exedir :=ExtractFileDir(ParamStr(0))+'\';
//login
  http.Host:='http://www.blubb.net/';  //erst mal zu seite verbinden und ne sessionid bekommen
  memo1.Lines.text:=http.Get('http://www.blubb.net/login.php');
//grafikcode laden, hier erst mal das code(in form von png) laden
try
  bild:=TPNGObject.Create;
  s:=tfilestream.Create(exedir+'Temppicture.png',fmcreate);
  bmp:=TBitmap.Create;
    try
      http.Get('http://www.blubb.net/grafikcode.php',s);
    finally
      s.Free;
    end;
  bild.LoadFromFile(exedir+'Temppicture.png');
  bmp.Assign(bild);
  image1.Height:=bild.Height;
  image1.Width:=bild.Width;
  image1.Picture.Bitmap:=bmp;
finally
  bild.Free;
  bmp.Free;
end;
deletefile(exedir+'Temppicture.png');
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  SL: TStringList;
begin
  memo1.Clear;
  SL := TStringList.Create;
  try
    SL.Add('submit=Einloggen');
    SL.Add('username='+loginedit.text);
    SL.Add('password='+Passwortedit.text);
    SL.Add('gcode='+GrafikcodeEdit.text);
    Memo1.Lines.Text:=HTTP.Post('http://www.blubb.net/login.php', SL);//einloggseite
    memo1.Lines.Text:=http.Get('http://www.blubb.net/index.php');//hier wird man danach umgeleitet
  finally
    SL.Free;
  end;
end;

Was ist daran falsch??? die reihenfolge wie ich das bild lade(nach dem ich die seite geladen habe) stimmt eigentlich, bin aber trotzdem nicht eingeloggt wenn ich den code sende(ist der falsch?).
mfg huhn

_________________
Quod Erat Demonstrandum-Was zu beweisen war! *THX to Chrissivo!*
huhn Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 272
Erhaltene Danke: 1

WIN XP
D7Pers
BeitragVerfasst: Sa 14.05.05 16:05 
Mein Gott bin ich ein Depp!! der fehler war das ich den quelltext nicht genau angeguckt habe!!! :twisted: :autsch:
ich hätte mir das ganzen kopfzerbrechen sparen können! Mein Delphiquelltext war eigentlich richtig!
ich hab nur die falschen parameter übergeben und war deshalbe nir eingeloggt
hier mein DÄMLICHER felher:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
<form action="login.php" method="post">
<input type="hidden" name="step" value="2">//die hier muss ich nehmen!!!
<table border=0 cellspacing=1 cellpadding=4 align="center" bgcolor="#000000" width="400">
  <tr>
    <td align="center" colspan=2 class="tblhead">Login</td>
  </tr>
  <tr>
    <td bgcolor="#cdcdcd" width="150" class="tbl">Benutzername:</td>
    <td bgcolor="#dddddd" class="tbl"><input type="text" name="username" value="" tabindex=1></td>
  </tr>
  <tr>
    <td bgcolor="#cdcdcd" class="tbl">Passwort:</td>
    <td bgcolor="#dddddd" class="tbl"><input type="password" name="password" value="" tabindex=2> <a href="lostpw.php">vergessen?</a></td>
  </tr>
  <tr>
    <td bgcolor="#cdcdcd" class="tbl">Grafikcode:</td>
    <td bgcolor="#dddddd" class="tbl"><input type="text" name="gcode" tabindex=3> (unten)</td>
  </tr>
  <tr>
    <td align="center" colspan=2 class="tblhead"><input type="submit" value="Einloggen" tabindex=4></td>//die parameter hab ich genommen(siehe delphitags(unter fehler) later!)
  </tr>
</table>

ich hab dann natürlich nie was gescheites zurückbekommen und so sah mein falscher para-übergabe aus:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
//falsch
procedure TForm1.Button1Click(Sender: TObject);
var
  SL: TStringList;
begin
  memo1.Clear;
  SL := TStringList.Create;
  try
    SL.Add('submit=Einloggen');//<-- hier is der sche*** fehler
    SL.Add('username='+loginedit.text);
    SL.Add('password='+Passwortedit.text);
    SL.Add('gcode='+GrafikcodeEdit.text);
    Memo1.Lines.Text:=HTTP.Post('http://www.blubb.net/login.php', SL);
    //http.Host:='http://www.jamaica-wars.net/index.php';
    //memo1.Lines.Text:=http.Get('http://www.blubb.net/index.php');
  finally
    SL.Free;
  end;
end;
//und jetzt richtig:
procedure TForm1.Button10Click(Sender: TObject);
var
  SL: TStringList;
begin
  memo1.Clear;
  SL := TStringList.Create;
  try
    SL.Add('step=2');//so muss des sein!
    SL.Add('username='+loginedit.text);
    SL.Add('password='+Passwortedit.text);
    SL.Add('gcode='+GrafikcodeEdit.text);
    Memo1.Lines.Text:=HTTP.Post('http://www.blubb.net/login.php', SL);
  finally
    SL.Free;
  end;
end;

Naja wenigstens hab ich nicht aufgegeben und ihn gefunden! Ich dank euch, auch wenn ihr nicht viel beigetragen habt(naja nur aus fehlern lernt man). :)
mfg huhn

_________________
Quod Erat Demonstrandum-Was zu beweisen war! *THX to Chrissivo!*