Ignore:
Timestamp:
Apr 30, 2011, 11:49:00 PM (14 years ago)
Author:
george
Message:
  • Modified: TSqlDatabase is now TComponent descendant.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Network/CoolWeb/WebServer/UHTTPSessionMySQL.pas

    r237 r238  
    1717  private
    1818    FSessionIdCookieName: string;
     19    FDatabase: TSqlDatabase;
    1920    FTimeout: Integer;
    2021    Lock: TCriticalSection;
     
    2223    procedure GetSessionId(HandlerData: THTTPHandlerData);
    2324  public
    24     SqlDatabase: TSqlDatabase;
    2525    Sessions: TStringList;
    2626    procedure Load(HandlerData: THTTPHandlerData); override;
     
    2929    destructor Destroy; override;
    3030  published
     31    property Database: TSqlDatabase read FDatabase write FDatabase;
    3132    property Timeout: Integer read FTimeout write FTimeout; // in seconds
    3233    property SessionIdCookieName: string read FSessionIdCookieName
     
    5556    try
    5657      DbRows := TDbRows.Create;
    57       SqlDatabase.Query(DbRows, 'SELECT * FROM `HTTPSession` WHERE `Identification`="' +
     58      Database.Query(DbRows, 'SELECT * FROM `HTTPSession` WHERE `Identification`="' +
    5859        Result + '"');
    5960      Found := DbRows.Count > 0;
     
    8384    Lock.Acquire;
    8485    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 ' +
    8687      IntToStr(Timeout) +' SECOND)');
    87     SqlDatabase.Query(DbRows, 'SELECT * FROM `HTTPSession` WHERE `Identification`="' +
     88    Database.Query(DbRows, 'SELECT * FROM `HTTPSession` WHERE `Identification`="' +
    8889      HandlerData.SessionId + '"');
    8990    if DbRows.Count > 0 then begin
     
    108109    DbRows := TDbRows.Create;
    109110    DbRows2 := TDbRows.Create;
    110     SqlDatabase.Query(DbRows, 'SELECT * FROM `HTTPSession` WHERE `Identification`="' +
     111    Database.Query(DbRows, 'SELECT * FROM `HTTPSession` WHERE `Identification`="' +
    111112      HandlerData.SessionId + '"');
    112113    if DbRows.Count > 0 then
    113       SqlDatabase.Query(DbRows2, 'UPDATE `HTTPSession` SET `Variables`="' + HandlerData.Session.Text
     114      Database.Query(DbRows2, 'UPDATE `HTTPSession` SET `Variables`="' + HandlerData.Session.Text
    114115        + '", `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 (' +
    116117    'NOW(), "' + HandlerData.Session.Text + '", "' + HandlerData.SessionId + '")');
    117118    HandlerData.Response.Cookies.Values[SessionIdCookieName] := HandlerData.SessionId;
Note: See TracChangeset for help on using the changeset viewer.