使用 IntraWeb (33) - Cookie

來源:互聯網
上載者:User

標籤:des   class   http   ext   使用   string   


在 IW.HTTP.Cookie 單元提供有兩個相關類: THTTPCookie、TCookieList; 另外 IWServerController 還有一個 CookieOptions 選項.

但實用起來一般用不到它們.
測試:
{讀取 Cookie; 放在 OnCreate 中不太合適, 因為在切換頁面時, 如果視窗沒被銷毀時 OnCreate 也不執行}procedure TIWForm1.IWAppFormRender(Sender: TObject); //OnRenderbegin  IWEdit1.Text := WebApplication.Request.CookieFields.Values[‘IWEdit1‘];end;{寫入 Cookie; 應該把它放在什麼事件中呢? 很傷腦筋, 譬如 OnDestroy 就不大合適, 因為在關掉頁面時它並不執行}procedure TIWForm1.IWEdit1AsyncChange(Sender: TObject; EventParams: TStringList); //IWEdit1.OnAsyncChangebegin  WebApplication.Response.Cookies.AddCookie(‘IWEdit1‘, IWEdit1.Text, ‘‘, Now+30); //參數 1: Cookie 名;                                                                                  //參數 2: Cookie 值;                                                                                  //參數 3: 有效範圍, 空表示當前網站;                                                                                  //參數 4: 有效時間, Now+30 表示 30 天內有效end;{遍曆 Cookie}procedure TIWForm1.IWButton1Click(Sender: TObject);var  str: string;begin  for str in WebApplication.Request.CookieFields do IWMemo1.Lines.Add(str);end;{關閉視窗}procedure TIWForm1.IWButton2Click(Sender: TObject);begin  WebApplication.Terminate;end;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.