i am trying to write a code that would allow single logon only...
if person A is logon at time 00:00 and person B is logon at time 00:01, person A will be automatically logout...
how can i do that with session?
the following code would tell person B that he cannot logon due to person A has already logon....how should i implement from this?
<?php
if ( $SERVER["REQUEST_METHOD"] <> 'POST' ) {
echo "<form method=\"POST\" action=\"" . $SERVER["REQUEST_URI"] . "\">\n";
echo "UID <input type=\"text\" name=\"uid\">\n";
echo "<br>please insert a number less than 102800<br>\n";
echo "<input type=\"submit\" value=\" Logon \">\n";
echo "</form>\n";
include "menu.php";
exit;
}
$uid = $_POST["uid"];
include "ssolib/sso_cache.inc";
$sso = new sso_cache;
$sso->open();
$ret = $sso->read($uid);
session_start();
if ( ( $ret[0] == '00000000000000000000000000000000' ) ||
( $ret[1] < time() - 5 * 60 ) ) {
$_SESSION["logon"] = $uid;
session_register('logon');
echo "<br>session is registered - your sid = " . session_id() . "<hr>\n";
echo "My uid : " . $uid . "<br>\n";
$sso->write($uid, session_id());
} else {
echo "DEBUG Current time is " . strftime("%T", time()) . "<br>\n";
echo "Sorry, you was logged-on from : at " . strftime("%T", $ret[1]) .
" with sid " . $ret[0] . "\n";;
echo "You try to logon again, we must clear your session<p>\n";
session_destroy();
}
$sso->close();