Autor Beitrag
stigge
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mi 03.10.07 13:15 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
<title>Logout</title>
<center>
<?php
if(isset($_COOKIE['pm_username']) AND isset($_COOKIE['pm_password']) AND $_COOKIE['pm_username'] != "" AND $_COOKIE['pm_password'] != "")
   {
setcookie ($_COOKIE['pm_username'], "", time()-1);
    setcookie ($_COOKIE['pm_password'], "", time()-1);
echo "Sie wurden erfolgreich ausgeloggt.";
   }   else
   {
     echo "Sie können sich nicht ausloggen wenn sie nicht eingeloggt sind.";
   }
?>
</center>

Jedes Mal wenn ich die Seite aufrufe kommt "Sie wurden erfolgreich ausgeloggt.".
Weiß jemand warum?
Oder löscht man Cookies irgendwie anders?
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mi 03.10.07 13:59 
Habs zum Laufen bekommen:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
<title>Logout</title>
<center>
<?php
if(isset($_COOKIE['pm_username']) AND isset($_COOKIE['pm_password']) AND $_COOKIE['pm_username'] != " " AND $_COOKIE['pm_password'] != " ")
   {
    @setcookie("pm_username", "", TIME - 86410, '/');
    @setcookie("pm_password", "", TIME - 86410, '/');
echo "Sie wurden erfolgreich ausgeloggt.";
   }   else
   {
     echo "Sie können sich nicht ausloggen wenn sie nicht eingeloggt sind.";
   }
?>
</center>
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mi 03.10.07 15:29 
Ich würd dir empfehlen, das ganze über Sessions zu lösen, das ist wesentlich komfortabler und läuft (wenn die Session-ID per GET übergeben wird) auch auf Browsern mit deaktivierten Cookies.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Christian V.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Do 04.10.07 14:25 
Ich schätze mal du hast das @ vor setcookie damit du keine Fehlermeldung bekommst.
Du darfst vor setcookie nur header informationen senden(nicht der Bereich im <head></head>).
Du kannst den Output buffern, und dann am schluss ausgeben:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
<?php
ob_start();
?>
<title>Logout</title>
<center>
<?php
if(isset($_COOKIE['pm_username']) AND isset($_COOKIE['pm_password']) AND $_COOKIE['pm_username'] != " " AND $_COOKIE['pm_password'] != " ")
   {
    setcookie("pm_username""", TIME - 86410'/');
    setcookie("pm_password""", TIME - 86410'/');
echo "Sie wurden erfolgreich ausgeloggt.";
   }   else
   {
     echo "Sie können sich nicht ausloggen wenn sie nicht eingeloggt sind.";
   }
?>
</center>
<?php
ob_end_flush();
?>

_________________
Hardware runs the world, software controls the hardware, code generates software - Have You already coded today?