Sitzungsverwaltung II

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]

lib/VShop/Session.pm
# return current time in YYYY-MM-DD HH:MM:SS format
sub timestamp {
   return time2str("%Y-%m-%d %X", time);
}

sub new_sessionid {
   my $sessions = TBI->open("Session");

   my $session; my $cnt = "aaa";
   do {
      $session = $cnt; $cnt ++;
      foreach (1..16) {
         $session .= ('.', '/', 0..9,
            'A'..'Z', 'a'..'z')[rand 64];
      }
   } while $sessions->exists($session);
   my $timestamp = timestamp();
   $sessions->add($session,
      login => "",
      start => $timestamp,
      lastuse => $timestamp,
   );
   return $session;
}

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]
Copyright © 1996 - 2003 Andreas Borchert, in HTML konvertiert am 01.10.2003