public static function addNewSessionKey($userName, $userId, $sessionKey) { $obj_retResult = new returnResult(); $db = config::dbconfig(); $id = DAL_manageWebService::getLastSessionId() + 1; $sql = "INSERT INTO tbl_webservicecall (id, userName, userId, sessionKey, startTime, lastUpdateTime) VALUES (" . $id . ",'" . $userName . "','" . $userId . "','" . $sessionKey . "',NOW(),NOW())"; $rs = mysql_query($sql); if (mysql_affected_rows() > 0) { $obj_retResult->type = 1; $obj_retResult->data = $sessionKey; } else { $obj_retResult->type = 0; } return $obj_retResult; }
public function validateSession($sessionKey) { $obj_retResult = new returnResult(); $obj_retResult->type = 0; $obj_result = DAL_manageWebService::getSessionKey($sessionKey); if ($obj_result->type == 1) { $obj_serviceSession = $obj_result->data; $nowTime = time(); $lastUpdateTime = strtotime($obj_serviceSession->lastUpdateTime); $lastUpdateTime = $lastUpdateTime + 1 * 60 * 60; //1 hour if ($lastUpdateTime < $nowTime) { $obj_retResult->msg = "Your session has expired"; } else { $obj_retResult->type = 1; $obj_retResult->data = $obj_serviceSession; $obj_retResult->msg = "Valid session"; DAL_manageWebService::updateSessionTime($sessionKey); } } return $obj_retResult; }