创建Cookies:
procedure TIWForm1.CreateTheCookie;
var
MyCookies: TstringList;
begin
try
MyCookies := TstringList.create;
MyCookies.Add('CookieName1=CookieValue1');
MyCookies.Add('CookieName2=CookieValue2');
Webapplication.Response.SetCookieField(
MyCookies, { 要设置的Cookies}
'', { 发送到Cookies的域名,如果为空的话,则使用当前的 }
'', { 发送到Cookies的路径,如果为空的话,则使用任意路径 }
Now+1, { Cookies的有效期 }
False { 是否使用加密的连接 }
);
finally
MyCookies.free;
end;
end;
读取Cookies:
procedure TIWForm1.ReadTheCookie;
var
Value1: String;
Value2: String;
begin
Value1 := webapplication.request.cookieFields.values['CookieName1'];
Value2 := webapplication.request.cookieFields.values['CookieName2'];
end;