unit Ucookietest;
interface
uses
Windows, Messages, SysUtils, Classes, HTTPApp;
type
TWebModule1 = class(TWebModule)
procedure WebModule1writecookieAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
procedure WebModule1readcookieAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
procedure WebModule1readcookie1Action(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
WebModule1: TWebModule1;
implementation
{$R *.DFM}
procedure TWebModule1.WebModule1writecookieAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
mycookies:TStringList;
begin
mycookies:=TStringList.Create;
with mycookies do
Begin
Add('Name=Frank Borland');
end;
with Response do
begin
SetCookieField(mycookies,'localhost','/',now+1,false);
content:='Cookies planted';
end;
mycookies.Free;
end;
/---- 이분분에서 값을 얻어오는데...
procedure TWebModule1.WebModule1readcookieAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
Response.content:=''+Request.cookie+'';
end;
//-- 값이 나오지를 않아요
//소스는 제데로 된것 같은데...
이런식으로 코딩을 했는데. 되질 않네요...
> unit Ucookietest;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Classes, HTTPApp;
>
> type
> TWebModule1 = class(TWebModule)
> procedure WebModule1writecookieAction(Sender: TObject;
> Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
> procedure WebModule1readcookieAction(Sender: TObject;
> Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
> procedure WebModule1readcookie1Action(Sender: TObject;
> Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> WebModule1: TWebModule1;
>
> implementation
>
> {$R *.DFM}
>
> procedure TWebModule1.WebModule1writecookieAction(Sender: TObject;
> Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
> var
> mycookies:TStringList;
> begin
> mycookies:=TStringList.Create;
> with mycookies do
> Begin
> Add('Name=Frank Borland');
> end;
> with Response do
> begin
> SetCookieField(mycookies,'localhost','/',now+1,false);
> content:='Cookies planted';
> end;
> mycookies.Free;
> end;
>
> /---- 이분분에서 값을 얻어오는데...
> procedure TWebModule1.WebModule1readcookieAction(Sender: TObject;
> Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
> begin
> Response.content:=''+Request.cookie+'';
> end;
> //-- 값이 나오지를 않아요
> //소스는 제데로 된것 같은데...
>
> 이런식으로 코딩을 했는데. 되질 않네요...
>
안녕하세요^^
우연하게 뉴스그룹을 보다가 요..
대충예기는 setcookiefield랑 sendredirect를 같은 action에서 사용을 못한다는 애기네요^^
그래서 저같은경우도 그랫었나 보네요..
다아시는건가?^^
I have tried the exact same thing, and my experience was that the cookie was
not written to the client when I used the same construction using
SetCookieField and then sendRedirect.
I had to return a normal response, and I solved it by filling the
Response.Content property with a dynamic created html-string containing only
a header and a metatag. The metatag was something like
HTTP-EQUIV="REFRESH" CONTENT="0 URL=%s">, where %s was replaced with the url
to my other dll (with parameters), and the cookiefield was just as before.
I thought this was a somewhat stupid an inefficient solution, but the
cookiefield was written to the client, and my other dll could read it and I
was happy...
If there are other (and better) solutions out there, please let me know!