Delphi intraweb ile SetCookie,GetCookie
uses a
iwinit,windows,IW.HTTP.Cookie function GetCookieValue(sName: String): String;
function GetUTCDateTime: TDateTime; var GMTST: Windows.TSystemTime; begin windows.GetSystemTime(GMTST); result:=Sysutils.SystemTimeToDateTime(GMTST); end; function GetCookieValue(sName: String): String; begin Result := webapplication.Request.CookieFields.Values[sName]; end;
procedure TFrm_Login.SetCookie; var ExpireOn : real; begin if ExpireIn <> 0 then ExpireOn := GetUTCDateTime + ExpireIn else ExpireOn:=-1; // session cookie webapplication.Response.Cookies.Add(THTTPCookie.Create(CookieName,CookieValue,'/',Expireon)) end;
procedure TFrm_Login.TIWAdvToolButton1Click(Sender: TObject); begin SetCookie('kullanici',edt_KullaniciAdi.Text,1); SetCookie('sifre',edt_Sifre.Text,1); end;
procedure TFrm_Login.IWAppFormShow(Sender: TObject); begin edt_KullaniciAdi.Text:=GetCookieValue('kullanici'); edt_Sifre.Text:=GetCookieValue('sifre'); end;