Question

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

Was it helpful?

Solution

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;

OTHER TIPS

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 :)

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top