Autor Beitrag
andras
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 460

Win XP, Win Vista Home Premium, Ubuntu Dapper Drake
Delphi 2005 Pers
BeitragVerfasst: Sa 19.05.07 11:47 
hi!
find ich super die neue sparte, da braucht man php-zeug nicht mehr ins offtopic geben und bekommt dafür diese unschönen sterne :lol:
aber zu meinem problem:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
<? if ((isset($_GET["category"])) and ($_GET["category"]=="home"))
  {
  if (!isset($_COOKIE['zaehler']))
  {
  header(setcookie("zaehler", time(), time() + 3600));
  $gesetzt = FALSE;
  }
  else
  {
  $gesetzt = TRUE;
  }
  if (isset($_COOKIE['besuch']))
  {
  $zeit=time()-(int)$_COOKIE['besuch'];
  }
  header(setcookie("besuch", time(), time()+ 321408000));
  }
?>

Mein Problem: Das Cookie "zaehler" gibt es nicht... und die variablen $gesetzt und $zeit zeigen nichts an wenn ich sie mit echo ausgeben will :( Cookies sind bei mir ohne ausnahmen erlaubt und "besuch" exisitiert ja...
Was ist an meinem code falsch??
Danke schon jetzt!
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Sa 19.05.07 22:26 
Ich würd das ganze per Sessions machen, da ist das ganze Cookie-Zeugs schon von PHP verwaltet, man muss nur noch Session_start aufrufen und man kann dann auf das Array $_SESSION zugreifen, dessen Inhalte dann auch weiter zur Verfügung stehen.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
LeoLöwe
ontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 45

Win XP Home
BDS 2006, PHPCoder
BeitragVerfasst: So 20.05.07 00:18 
Probier mal:

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:
27:
28:
29:
<? 
if ((isset($_GET["category"])) and ($_GET["category"]=="home")) 


   if (!isset($_COOKIE['zaehler'])) 
   { 

      setcookie("zaehler", time(), time() + 3600); 
      $gesetzt = FALSE; 

   } 
   else 
   { 

      $gesetzt = TRUE; 

   } 

   if (isset($_COOKIE['besuch'])) 
   { 

      $zeit=time()-(int)$_COOKIE['besuch']; 

   } 

   setcookie("besuch", time(), time()+ 321408000); 


?>


Oder, mit den Sessions:

ausblenden volle Höhe 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:
<?

session_start();

if ((isset($_GET["category"])) and ($_GET["category"]=="home")) 
{

   if(!isset($_SESSION['zaehler']))
   {
      $_SESSION['zaehler'] = time();
      $gesetzt = FALSE;
   }
   else
   {
      $gesetzt = TRUE;

      if($_SESSION['zaehler']<time()-3600)
      {
         unset($_SESSION['zaehler']);
         $gesetzt = FALSE;
      }
   }

   if (isset($_SESSION['besuch'])) 
   { 

      $zeit=time()-(int)$_SESSION['besuch']; 

   } 

   $_SESSION['besuch'] = time();
}
?>
andras Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 460

Win XP, Win Vista Home Premium, Ubuntu Dapper Drake
Delphi 2005 Pers
BeitragVerfasst: So 20.05.07 04:11 
also, das von user profile iconLeoLöwe mit den Cookies geht nicht, da hat sich gar nix getan :( aber ich werd das ganze einmal auf sessions umstellen, die schaun halbwegs vernünftig aus...
aber wie schaut das aus, wenn ich etwas über einen längeren zeitraum speichern will, auch nachdem der pc abgeschaltet/browser gschlossen wurde? seesion exisitieren doch nur für diese spezielle seite und sind dann wieder weg, oder irre ich mihc da?
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: So 20.05.07 11:28 
Richtig und du musst bei jedem Seitenauruf die S(ession-)ID übergeben.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Di 22.05.07 20:15 
user profile iconGTA-Place hat folgendes geschrieben:
Richtig und du musst bei jedem Seitenauruf die S(ession-)ID übergeben.

Hm also eigentlich nicht. Bei meinem Projekten wird die SID nicht per URL übergeben und es funktioniert :gruebel:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
andras Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 460

Win XP, Win Vista Home Premium, Ubuntu Dapper Drake
Delphi 2005 Pers
BeitragVerfasst: Mi 23.05.07 13:14 
user profile iconMarco D. hat folgendes geschrieben:
user profile iconGTA-Place hat folgendes geschrieben:
Richtig und du musst bei jedem Seitenauruf die S(ession-)ID übergeben.

Hm also eigentlich nicht. Bei meinem Projekten wird die SID nicht per URL übergeben und es funktioniert :gruebel:
:?!?: :gruebel: also was jetzt :rofl:
könnte mir bitte jemand einmal genau erklären was die SID eig ist, bis jetzt hab ich nur rausgefunden dass die einmalig ist, aber sonst eig nix...
Thx!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 23.05.07 14:16 
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 23.05.07 16:10 
@Luckie: Lies das Topic nochmal ganz und nicht nur die Buchstaben "SID" ;-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 24.05.07 08:33 

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Pepe
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 107

Win 98, Win 2000 Prof., Win XP Prof.
Delphi 2005 Prof.
BeitragVerfasst: Do 31.05.07 09:52 
du solltest bei deinem setcookie aufruf auch die domain und den ordner etc. mit angeben... sonst akzeptieren die browser das cookie ab einer gewissen sicherheits (ich glaub sogar bei minimal schon) nicht mehr!
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Do 31.05.07 11:02 
Ich setze meine Cookies so:
ausblenden Quelltext
1:
setcookie('VBet[nick]', '', time() - 3600, '/');					

Ohne das gehighlightete funktioniert der Cookie nur im aktuellen Verzeichnis!

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)