Jump to content

Recommended Posts

I have a timer and it times out is there anyway that i can make that timer give the user a window to extend the timer to stay signed on.

because everytime it times out the user is no longer signed in on the system so some of the features I am afraid stop working.

timer in question is below.

 

thanks

 

<?php

 

include("dbinfo.php");

 

// Set length of session to twenty minutes

define("SESSION_LENGTH", 20);

 

$sConn = @mysql_connect($dbServer, $dbUser, $dbPass)

or die("Couldnt connect to database");

 

$dbConn = @mysql_select_db($dbName, $sConn)

or die("Couldnt select database $dbName");

 

 

$timeMax = time() - (60* SESSION_LENGTH);

 

$result = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax' and permission = '0'");

$usersOnline = mysql_result($result, 0, 0);

 

$resulta = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax' and permission = '1'");

$usersOnline2 = mysql_result($resulta, 0, 0);

 

$resultb = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax' and permission = '2'");

$usersOnline3 = mysql_result($resultb, 0, 0);

 

 

 

$connect = mysql_connect("localhost", "user", "pass") or die("Could not connect to database: " . mysql_error());

mysql_select_db("db", $connect) or die("Could not select database");

$result3 = mysql_query("SELECT COUNT(*) AS count FROM users WHERE permission = '0'");

$row = mysql_fetch_array($result3);

 

$result4 = mysql_query("SELECT COUNT(*) AS count FROM users WHERE permission = '1'");

$row2 = mysql_fetch_array($result4);

 

echo "" . ($usersOnline2 != 1 ? "" : "") . " $usersOnline2 Admin" . ($usersOnline2 != 1 ? "s" : "") ." of $row2[count]. ". " </br> ". ($usersOnline3 != 1 ? "" : "") . " $usersOnline3 Guest" . ($usersOnline3 != 1 ? "s" : "") ."." . " </br> " . ($usersOnline != 1 ? "" : "") . " $usersOnline User" . ($usersOnline != 1 ? "s" : "") ." of $row[count]" . ". ";

?>

 

Link to comment
https://forums.phpfreaks.com/topic/62981-users-online-question/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.