Changeset 238 for Network/CoolWeb/WebServer/UHTTPSessionMySQL.pas
- Timestamp:
- Apr 30, 2011, 11:49:00 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Network/CoolWeb/WebServer/UHTTPSessionMySQL.pas
r237 r238 17 17 private 18 18 FSessionIdCookieName: string; 19 FDatabase: TSqlDatabase; 19 20 FTimeout: Integer; 20 21 Lock: TCriticalSection; … … 22 23 procedure GetSessionId(HandlerData: THTTPHandlerData); 23 24 public 24 SqlDatabase: TSqlDatabase;25 25 Sessions: TStringList; 26 26 procedure Load(HandlerData: THTTPHandlerData); override; … … 29 29 destructor Destroy; override; 30 30 published 31 property Database: TSqlDatabase read FDatabase write FDatabase; 31 32 property Timeout: Integer read FTimeout write FTimeout; // in seconds 32 33 property SessionIdCookieName: string read FSessionIdCookieName … … 55 56 try 56 57 DbRows := TDbRows.Create; 57 SqlDatabase.Query(DbRows, 'SELECT * FROM `HTTPSession` WHERE `Identification`="' +58 Database.Query(DbRows, 'SELECT * FROM `HTTPSession` WHERE `Identification`="' + 58 59 Result + '"'); 59 60 Found := DbRows.Count > 0; … … 83 84 Lock.Acquire; 84 85 DbRows := TDbRows.Create; 85 SqlDatabase.Query(DbRows, 'DELETE FROM `HTTPSession` WHERE `Time` < DATE_SUB(NOW(), INTERVAL ' +86 Database.Query(DbRows, 'DELETE FROM `HTTPSession` WHERE `Time` < DATE_SUB(NOW(), INTERVAL ' + 86 87 IntToStr(Timeout) +' SECOND)'); 87 SqlDatabase.Query(DbRows, 'SELECT * FROM `HTTPSession` WHERE `Identification`="' +88 Database.Query(DbRows, 'SELECT * FROM `HTTPSession` WHERE `Identification`="' + 88 89 HandlerData.SessionId + '"'); 89 90 if DbRows.Count > 0 then begin … … 108 109 DbRows := TDbRows.Create; 109 110 DbRows2 := TDbRows.Create; 110 SqlDatabase.Query(DbRows, 'SELECT * FROM `HTTPSession` WHERE `Identification`="' +111 Database.Query(DbRows, 'SELECT * FROM `HTTPSession` WHERE `Identification`="' + 111 112 HandlerData.SessionId + '"'); 112 113 if DbRows.Count > 0 then 113 SqlDatabase.Query(DbRows2, 'UPDATE `HTTPSession` SET `Variables`="' + HandlerData.Session.Text114 Database.Query(DbRows2, 'UPDATE `HTTPSession` SET `Variables`="' + HandlerData.Session.Text 114 115 + '", `Time` = NOW() WHERE `Identification`="' + HandlerData.SessionId + '"') 115 else SqlDatabase.Query(DbRows2, 'INSERT INTO `HTTPSession` (`Time`, `Variables`, `Identification`) VALUES (' +116 else Database.Query(DbRows2, 'INSERT INTO `HTTPSession` (`Time`, `Variables`, `Identification`) VALUES (' + 116 117 'NOW(), "' + HandlerData.Session.Text + '", "' + HandlerData.SessionId + '")'); 117 118 HandlerData.Response.Cookies.Values[SessionIdCookieName] := HandlerData.SessionId;
Note:
See TracChangeset
for help on using the changeset viewer.