【问题标题】:How to set or change cookie value in Chromium?如何在 Chromium 中设置或更改 cookie 值?
【发布时间】:2015-07-01 21:54:01
【问题描述】:

如何在 Chromium 中设置或更改 cookie 值?

这不起作用:

CookieManager := TCefCookieManagerRef.Global;
  CookieManager.VisitAllCookiesProc(
    function(const name, Value, domain, path: ustring;
      secure, httponly, hasExpires: Boolean; const creation, lastAccess,
      expires: TDateTime; Count, total: Integer;
      out deleteCookie: Boolean): Boolean
    begin
      deleteCookie := False;
      ShowMessage(name + ': ' + Value);
      CookieManager.SetCookie('', name, Value + 'aaaa', domain, path, secure,
        httponly, hasExpires, creation, lastAccess, expires);
      Result := True;
    end);

【问题讨论】:

  • 怎么不工作?会发生什么?
  • 当我再次运行它时,值没有改变。应在值中添加“aaa”。非常感谢。

标签: delphi cookies components chromium


【解决方案1】:

SetCookie函数中不能使用空url,根据域添加url即可。

SetCookie('http://=your site=/' ...

这可以正常工作。

另外,您不必在 VisitAllCookiesProc 中使用另一种解决方案

  TCefFastTask.New(TID_IO, procedure
    begin
      CookieManager.SetCookie('http://=your site=/'...
    end
  );

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-04
    • 2012-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-14
    • 2016-02-06
    • 2020-02-18
    相关资源
    最近更新 更多