惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
T
Tailwind CSS Blog
The Cloudflare Blog
The Last Watchdog
The Last Watchdog
PCI Perspectives
PCI Perspectives
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
TaoSecurity Blog
TaoSecurity Blog
云风的 BLOG
云风的 BLOG
C
Cybersecurity and Infrastructure Security Agency CISA
O
OpenAI News
Recorded Future
Recorded Future
GbyAI
GbyAI
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Y
Y Combinator Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
量子位
博客园 - 叶小钗
V
Vulnerabilities – Threatpost
F
Full Disclosure
Recent Announcements
Recent Announcements
Vercel News
Vercel News
S
Schneier on Security
H
Heimdal Security Blog
Cisco Talos Blog
Cisco Talos Blog
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
B
Blog RSS Feed
宝玉的分享
宝玉的分享
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy & Cybersecurity Law Blog
T
Threat Research - Cisco Blogs
G
Google Developers Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
爱范儿
爱范儿
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
N
Netflix TechBlog - Medium
S
Security @ Cisco Blogs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyberwarzone
Cyberwarzone

博客园 - 万一

关于内存数据与 JSON 高亮 TRichEdit 当前行 使用 IntraWeb (45) - 活用 IntraWeb 使用 IntraWeb (44) - 测试读取 SqLite (三) 使用 IntraWeb (43) - 测试读取 SqLite (二) 使用 IntraWeb (42) - 测试读取 SqLite (一) 使用 IntraWeb (41) - 数据控件速查 使用 IntraWeb (40) - 自定义 Session 数据 使用 IntraWeb (39) - THttpRequest、THttpReply 使用 IntraWeb (38) - TIWAppForm、TIWForm、TIWBaseHTMLForm、TIWBaseForm 使用 IntraWeb (37) - TIWApplication 使用 IntraWeb (36) - TIWServerControllerBase 使用 IntraWeb (35) - TIWJQueryWidget 使用 IntraWeb (34) - TIWAJAXNotifier 使用 IntraWeb (32) - Url 映射与 THandlers 使用 IntraWeb (31) - IntraWeb 的 Xml 操作使用的是 NativeXml 使用 IntraWeb (30) - TIWAppInfo、TIWMimeTypes、TIWAppCache 使用 IntraWeb (29) - 基本控件之 TIWAutherList、TIWAutherINI、TIWAutherEvent 使用 IntraWeb (28) - 基本控件之 TIWTemplateProcessorHTML、TIWLayoutMgrHTML、TIWLayoutMgrForm
使用 IntraWeb (33) - Cookie
万一 · 2014-06-24 · via 博客园 - 万一

在 IW.HTTP.Cookie 单元提供有两个相关类: THTTPCookie、TCookieList; 另外 IWServerController 还有一个 CookieOptions 选项.

但实用起来一般用不到它们.


测试:



{读取 Cookie; 放在 OnCreate 中不太合适, 因为在切换页面时, 如果窗口没被销毁时 OnCreate 也不执行}
procedure TIWForm1.IWAppFormRender(Sender: TObject); //OnRender
begin
  IWEdit1.Text := WebApplication.Request.CookieFields.Values['IWEdit1'];
end;

{写入 Cookie; 应该把它放在什么事件中呢? 很伤脑筋, 譬如 OnDestroy 就不大合适, 因为在关掉页面时它并不执行}
procedure TIWForm1.IWEdit1AsyncChange(Sender: TObject; EventParams: TStringList); //IWEdit1.OnAsyncChange
begin
  WebApplication.Response.Cookies.AddCookie('IWEdit1', IWEdit1.Text, '', Now+30); //参数 1: Cookie 名;
                                                                                  //参数 2: Cookie 值;
                                                                                  //参数 3: 有效范围, 空表示当前站点;
                                                                                  //参数 4: 有效时间, Now+30 表示 30 天内有效
end;

{遍历 Cookie}
procedure TIWForm1.IWButton1Click(Sender: TObject);
var
  str: string;
begin
  for str in WebApplication.Request.CookieFields do IWMemo1.Lines.Add(str);
end;

{关闭窗口}
procedure TIWForm1.IWButton2Click(Sender: TObject);
begin
  WebApplication.Terminate;
end;