不用什么Repson,Request的,因为我只想修改本地的cook。可是用InternetSetCookie总也没有效果,谁来教教我?
我是这样写的:
var
cookbuffer:array[0..20] of char
begin
cookbuffer[0]:='r';
InternetSetCookie(PChar('http://www.xxxx.com'),pchar('userName'),@cookBuffer);
end;
可是在IE文件夹里察看,总是没有改!(我在同样的地址用InternetGetCookie取出过COOK)
我是这样写的:
var
cookbuffer:array[0..20] of char
begin
cookbuffer[0]:='r';
InternetSetCookie(PChar('http://www.xxxx.com'),pchar('userName'),@cookBuffer);
end;
可是在IE文件夹里察看,总是没有改!(我在同样的地址用InternetGetCookie取出过COOK)
用10代替),这样就可以建立Cookie了. 以下为建立一个访问计数器的程序,可以参照:
const
LastIp:String='0:0:0:0'; //避免重复计数
Var
S:String;
Count:Integer;
begin
S:=Request.CookieFields.Values['count'];
if S< > '' then begin
try
Count:=StrToInt(S);
Except
Count:=0;
End;
end else Count:=0;
if LastIp< > Request.RemoteAddr then Inc(Count);
LastIp:=Request.RemoteAddr;
Response.SetCustomHeader('Set-Cookie','count='+IntToStr(Count)+';
expires=Sun, 21 Feb 2010 08:08:08 GMT');
Response.Content:='您是第'+IntToStr(Count)+'来到本页!';
End;
cookbuffer:array[0..20] of char
str1:string;
begin
str1:='要写的值;expires=Sun,22Feb2099 08:08:08 GMT';
StrPCopy(cookBuffer,str1);
InternetSetCookie(PChar('http://www.xxxx.com'),pchar'userName'),@cookBuffer);
end;
这样就把userName的值写进去了。