PHP Classes

File: del_session.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Carlos Falo Hervás  >  basic_basket  >  del_session.php  >  Download  
File: del_session.php
Role: Application script
Content type: text/plain
Description: Eliminates old client sessions and removes old data from basket
Class: basic_basket
Basic Shopping basket system
Author: By
Last change:
Date: 14 years ago
Size: 1,313 bytes


Class file image Download
// 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 (
    while (!
// 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() ;