Re-insert the row into online if it has been removed.
authorJoey Schulze <joey@infodrom.org>
Wed, 2 Jul 2008 13:52:59 +0000 (13:52 +0000)
committerJoey Schulze <joey@infodrom.org>
Wed, 2 Jul 2008 13:52:59 +0000 (13:52 +0000)
Maybe the session should be expired instead?

lib/session.inc

index c8293f1..27a8cda 100644 (file)
@@ -100,7 +100,11 @@ function session_init()
       session_invalidate('login.html?from=session');
 
     $query = sprintf('UPDATE online SET activity = now() WHERE uid = %d', $_SESSION['uid']);
-    db_query($query);
+    $sth = db_query($query);
+    if (pg_affected_rows($sth) < 1) {
+      $query = sprintf('INSERT INTO online (uid,activity) VALUES (%d,now())', $_SESSION['uid']);
+      $sth = db_query($query);
+    }
 
     if ($_SESSION["lastupdate"] < time() - 60) {
       session_update();