一起学libcef--给你的浏览器删除cookie
生活随笔
收集整理的這篇文章主要介紹了
一起学libcef--给你的浏览器删除cookie
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
long long ago, 我們討論了如給你cef設(shè)置cookie.
如今來補(bǔ)充一點(diǎn),假設(shè)給你的瀏覽器刪除某一cookie。
review一下設(shè)置cookie:
std::wstring username_key = L"username";
std::wstring username_value = L"xidada";
std::wstring domain = L"blog.csdn.net"
CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager();
CefCookie cookie;
CefString(&cookie.name).FromWString(username_key.c_str());
CefString(&cookie.value).FromWString(username_value.c_str());
CefString(&cookie.domain).FromWString(domain.c_str());
CefString(&cookie.path).FromASCII("/");
cookie.has_expires = false;
domain = L"https://" + domain;
CefPostTask(TID_IO, NewCefRunnableMethod(manager.get(), &CefCookieManager::SetCookie,CefString(domain.c_str()), cookie));
//創(chuàng)建瀏覽器
CefBrowserHost::CreateBrowser(info, g_web_browser_client.get(),
domain.c_str(), browserSettings, NULL);
如今就開始刪除某一cookie:
DeleteCookies
看看函數(shù)描寫敘述:
// Delete all cookies that match the specified parameters. If both |url| and
// values |cookie_name| are specified all host and domain cookies matching
// both will be deleted. If only |url| is specified all host cookies (but not
// domain cookies) irrespective of path will be deleted. If |url| is empty all
// cookies for all hosts and domains will be deleted. Returns false if a non-
// empty invalid URL is specified or if cookies cannot be accessed. This
// method must be called on the IO thread.
///
/*--cef(optional_param=url,optional_param=cookie_name)--*/
virtual bool DeleteCookies(const CefString& url,
const CefString& cookie_name) =0;
應(yīng)用:
CefPostTask(TID_IO, NewCefRunnableMethod(manager.get(), &CefCookieManager::DeleteCookies,
CefString(domain.c_str()), CefString("username")));
以上代碼就刪除了為”blog.csdn.net”設(shè)置的cookie:
username = xidada
總結(jié)
以上是生活随笔為你收集整理的一起学libcef--给你的浏览器删除cookie的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 牙齿伸长正畸需要多少钱
- 下一篇: Spring声明式事务