PHP Classes

File: del_session

Recommend this page to a friend!
  Classes of kostas gougakis   Shopping basket with MySQL connection   del_session   Download  
File: del_session
Role: Auxiliary script
Content type: text/plain
Description: del_session finalize basket hold
Class: Shopping basket with MySQL connection
Shopping basket stored in a MySQL database
Author: By
Last change:
Date: 20 years ago
Size: 1,313 bytes
 

Contents

Class file image Download
<?PHP
// Ending Session info is important to clean up current active operations
// Also unfinished abandoned sessions will be removed from the system
   
 
$rs = new mysql_recordset("conn","SELECT * FROM tbl_active_sessions") ;
  if (
$rs->query())
    {
    while (!
$rs->movenext())
      {
   
// This is just one way to do it, normally performance will not be compromised as
    // long concurrent sessions don't grow too much... in this case a 2 pass process
    // deleting directly based on tbl_active_sessions start time (first from tbl_carrito and then from
    // tbl_active_sessions will attune for improved performance. Used this approach as it is far
    // more clear to understand than the 'advanced' method
           
     
$timeactual = time(); //current time to check session expiry
     
if ($rs->value("start") < $timeactual-10800) //expiration = 3 hours
       
{
       
// DELETE FROM active_sessions and from shopping basket tables
      
$comm = new mysql_command("conn","DELETE FROM tbl_basket WHERE sessionid = '" . $rs->value("sessionid") . "'") ;
      
$comm->execute() ;
      
$comm->sqlstring = "DELETE FROM tbl_active_sessions WHERE sessionid = '" . $rs->value("sessionid") . "'" ;
      
$comm->execute() ;
       }
     }
  
$rs->clear_recordset() ;
   }
?>