Eitan Arbel
Eitan Arbel

Reputation: 66

Delphi XE2, Intraweb 2.1.23 and cookies

i did everything exactly the same as in the cookies example (shown here http://www.atozed.com/intraweb/docs/Develop/Cookies.aspx), but it's not compiling and it says "[DCC Error] Login.pas(38): E2035 Not enough actual parameters" and places the courser right after the "WebApplication.Response.Cooki­es.Add"

what am i missing? is there a unit i need to add to the uses?

i use Delphi XE2, and Intraweb 2.1.23 oh, and i'm new to intraweb...

please help thank you

Upvotes: 1

Views: 2101

Answers (3)

Willian Santos
Willian Santos

Reputation: 1

My Code:

procedure SetCookie(AIWApplication: TIWApplication; AName, AValue: string; AExpiration: TDate);
var
   LCookie: TCookie;
begin
   AIWApplication.Response.Cookies.Add(LCookie);
 with LCookie do
 begin
   Name := AName;
   Value := AValue;
   Expires := AExpiration;
 end;
end;

Upvotes: -2

Lenn Dolling
Lenn Dolling

Reputation: 1300

Here is a working code block that will create a Cookie in Intraweb 12.2.8 XE2

make sure that you add IW.HTTP.Cookie in your uses clause.

and of course you will have to modify the TiwfrmMain to match your iwform and also declare the procedure :) via: procedure MakeCookie; in your

procedure TiwfrmMain.MakeCookie;
    var cookieMain: THttpCookie;

begin

 try
  cookieMain:=  THttpCookie.Create('email',editLogin.Text,'',Date + 999);
  WebApplication.Response.Cookies.Add(cookieMain);
  cookieMain.free;  
 except

 end;

end;

and you can also then get it via:

procedure TiwfrmMain.SetCookie;
begin
  try


    if WebApplication.Request.CookieFields.IndexOfName('email')> -1 then
    editLogin.Text := WebApplication.Request.CookieFields.Values['email'];


  except

  end;

end;

njoy :)

Upvotes: 2

M Schenkel
M Schenkel

Reputation: 6364

Make sure httpapp is in your uses clause and try something like this:

procedure TIWServerController.SetCookie;
var
  mCookie: TCookie;
begin
  mCookie := WebApplication.Response.Cookies.Add;
  with mCookie do begin
    Name:='mycookie';
    Value:='mycookievalue';
    Expires := Date + 30;
  end;
end;

Upvotes: 3

Related Questions