I've got a php page where my customers log-to the application. It's working fine. Yesterday, out of the blue the customers could login but were forced out and rerouted towards the login page again.

My database has drenched within the user's login timings which problem was instantly solved after a couple of hrs.

Why will enjoy this happen?


Within the following code it'll look for the session value and when it's not found then redirect towards the error page. Yesterday, it had been redirecting to error page even when the session value was set.

<?php
if($_SESSION['ucd']<>"" && $_SESSION['sid']<>"" && $_SESSION['sid']<>0)
{
$query="select count(*) from active_sessions where user_cd='".$_SESSION['ucd']."'
and session_no='".$_SESSION['sid']."' and START_TM like DATE_FORMAT(now(),'%Y-%m-%d%')";
//echo $query;
$cnt=$dbop->select($query);
if($cnt[0] == '0')
{
$sender = "sender=".urlencode($_SERVER['PHP_SELF']);
session_unset();
header("Location:../login/error.html?$sender");
die;
}
else{
$query = "update active_sessions set LAST_ACTIVITY = NOW() WHERE SESSION_NO = ".$_SESSION['sid'];
mysql_query($query);
?>

<?php
}
}
else
{
$sender = "sender=".urlencode($_SERVER['PHP_SELF']);
session_unset();
header("Location:../login/error.html?$sender");
die;
}
?>

I do not see session_start() any place in your code.