Hi
I am looking to create a site where a session lasts 30 minutes. There is a session table that is updated with a list of new sessions. I have the following thing coded. But I noticed that there are over 213 sessions created although the test-site only had 23 pageviews from 10 visits or so (which means 10 sessions at the maximum). Could you please tell me where I am going wrong that there were over 213 sessions created in one day?
I am looking to create a site where a session lasts 30 minutes. There is a session table that is updated with a list of new sessions. I have the following thing coded. But I noticed that there are over 213 sessions created although the test-site only had 23 pageviews from 10 visits or so (which means 10 sessions at the maximum). Could you please tell me where I am going wrong that there were over 213 sessions created in one day?
HTML:
session_start();
$result=mysql_query("SELECT * FROM $database_name.sessiontable_name WHERE id='".session_id()."';",$databaseconnect);
$row = mysql_fetch_array($result);
$id=$row["id"];
$b=false;
if(count($id)==0){
$t=date("i");
$id=session_id();
$q="INSERT INTO $database_name.sessiontable_name (id, timesession) VALUES (\"$id\", $t);";
mysql_query($q);
$b=true;
}
else{
$t=intval($row["timesession"]);
if(abs($t-intval(date("i")))>30){
$t=date("i");
$id=session_id();
mysql_query("UPDATE $database_name.sessiontable_name SET timesession=$t WHERE id=\"$id\";");
$b=true;
}
}