H
hubdog
Unregistered / Unconfirmed
GUEST, unregistred user!
我想在一个Actionitem中增加cookie,然后sendredirect到另一个actionitem
在那里验证cookie,有cookie这显示一个页面,否则返回.
但我发现增加完cookie后,如果马上sendredirect则另一个actionitem取不到cookie值(说明cookie增加不成功),若不马上sendredirect而是
response.content:='某一页面内容',然后用户点击连结到另一ActionItem
则可以成功读出cookie.Why ? Solution?
procedure TWebModuleWord.WebModuleItemLoginAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
UserName,UserPwd:string;
Tempstr:tstrings;
begin
if request.methodtype=mtpost then
begin
UserName:='';UserPwd:='';
TempStr:=TStringList.Create;
request.ExtractContentFields(TempStr);
UserName:=GetValueOfPost(TempStr.Strings[0]);
UserPwd:=GetValueOfPost(TempStr.Strings[1]);
TempStr.Free;
//添加cookie
with Response.Cookies.Add do
begin
Name:='UserName';
Value:=UserName;
end;
with Response.Cookies.Add do
begin
Name:='UserPwd';
Value:=UserPwd;
end;
response.content:='right login';
//Response.SendRedirect('http://hubdog/hubdog.exe/hubdog');
end;
end;
end;
在那里验证cookie,有cookie这显示一个页面,否则返回.
但我发现增加完cookie后,如果马上sendredirect则另一个actionitem取不到cookie值(说明cookie增加不成功),若不马上sendredirect而是
response.content:='某一页面内容',然后用户点击连结到另一ActionItem
则可以成功读出cookie.Why ? Solution?
procedure TWebModuleWord.WebModuleItemLoginAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
UserName,UserPwd:string;
Tempstr:tstrings;
begin
if request.methodtype=mtpost then
begin
UserName:='';UserPwd:='';
TempStr:=TStringList.Create;
request.ExtractContentFields(TempStr);
UserName:=GetValueOfPost(TempStr.Strings[0]);
UserPwd:=GetValueOfPost(TempStr.Strings[1]);
TempStr.Free;
//添加cookie
with Response.Cookies.Add do
begin
Name:='UserName';
Value:=UserName;
end;
with Response.Cookies.Add do
begin
Name:='UserPwd';
Value:=UserPwd;
end;
response.content:='right login';
//Response.SendRedirect('http://hubdog/hubdog.exe/hubdog');
end;
end;
end;