使用 IntraWeb (40) - 自定义 Session 数据
2021-04-29 23:26
302 查看
使用 IntraWeb (40) - 自定义 Session 数据
修改 UserSessionUnit 单元:
unit UserSessionUnit; interface uses IWUserSessionBase, SysUtils, Classes, IWApplication; type TIWUserSession = class(TIWUserSessionBase) procedure IWUserSessionBaseCreate(Sender: TObject); procedure IWUserSessionBaseDestroy(Sender: TObject); private FMyName: string; FMyAge: Integer; FMyInfos: TStrings; public property MyName: string read FMyName write FMyName; property MyAge: Integer read FMyAge write FMyAge; property MyInfos: TStrings read FMyInfos write FMyInfos; end; implementation {$R *.dfm} procedure TIWUserSession.IWUserSessionBaseCreate(Sender: TObject); begin FMyInfos := TStringList.Create; end; procedure TIWUserSession.IWUserSessionBaseDestroy(Sender: TObject); begin FMyInfos.Free; end; end.
测试从 Unit1 写入数据:
uses ServerController, Unit2; procedure TIWForm1.IWButton1AsyncClick(Sender: TObject; EventParams: TStringList); begin UserSession.MyName := 'aaa'; UserSession.MyAge := 111; UserSession.MyInfos.Add('Var1=123'); UserSession.MyInfos.Add('Var2=456'); TIWForm2.Create(WebApplication).Show; end;
测试从 Unit2 读取数据:
uses ServerController; procedure TIWForm2.IWButton1AsyncClick(Sender: TObject; EventParams: TStringList); begin IWMemo1.Lines.Add(UserSession.MyName); IWMemo1.Lines.Add(UserSession.MyAge.ToString()); IWMemo1.Lines.Add(UserSession.MyInfos.Values['Var1']); IWMemo1.Lines.Add(UserSession.MyInfos.Values['Var2']); end;
相关文章推荐
- 使用 IntraWeb (2) - Hello IntraWeb
- 使用 IntraWeb (41) - 数据控件速查
- 使用 IntraWeb (42) - 测试读取 SqLite (一)
- 使用 IntraWeb (43) - 测试读取 SqLite (二)
- 使用 IntraWeb (45) - 活用 IntraWeb
- 使用 IntraWeb (1) - 先测试如何部署为 Asp.Net 的应用
- 使用 IntraWeb (25) - 基本控件之 TIWRegion
- 使用 IntraWeb (44) - 测试读取 SqLite (三)
- 使用defineProperty实现自定义setter, 简化前端Angular的重构工作
- 从一个 10 年程序员的角度告诉你:搞懂 Java 面向对象有多容易?
- Api接口:手机空号状态过滤检测
- Python工程师的大数据之路(6c)Kafka理论知识
- 邮递员算法问题之c++实现
- API 版本控制小技巧
- STM32属于哈佛结构还是冯诺依曼结构?
- windows10使用docker搭建开发环境
- Java 基础 一文搞懂泛型
- Mybatis(一)Porxy动态代理和sql解析替换
- IOS Widget(1):概述
- BLE链路层空中包格式