My current structure of planning is this:
table -sessions-
sid = sessionid
name = username (or default: guest)
lastclick = last recorded time of activity
ip = ip address of user
current rows:
1x1x1x1x, guest, 000000, 1.1.1.1
When a guest comes to a page:
(please note: code is shorthand, may contain common mistakes :/)
Is there any better way to work this out? I do not like to run 3 query's on every page...when I could probably do it in less
I'm working on a forum and starting with 3 query's just for 1 member on each page is gonna slow things down from the start
thanks
table -sessions-
sid = sessionid
name = username (or default: guest)
lastclick = last recorded time of activity
ip = ip address of user
current rows:
1x1x1x1x, guest, 000000, 1.1.1.1
When a guest comes to a page:
(please note: code is shorthand, may contain common mistakes :/)
PHP:
$ip = getenv('remote_addr');
$userid = $_COOKIE['userid'];
if (empty($userid))
{
// user is guest
query("SELECT * FROM sessions WHERE ip='$ip' and name='guest' LIMIT 1");
$id = row('sid');
query("UPDATE sessions SET last_click='time()' WHERE sid=$sid LIMIT 1");
query("DELETE * FROM sessions WHERE lastclick<time()-10minutes");
} else
{
// Same thing but this involves a logged in user
}
Is there any better way to work this out? I do not like to run 3 query's on every page...when I could probably do it in less
I'm working on a forum and starting with 3 query's just for 1 member on each page is gonna slow things down from the start
thanks
















