win10
vs2010 32位的
下载cef代码,然后编译库
https://www.cnblogs.com/honfu/p/11478785.html
https://blog.csdn.net/lengyue2015/article/details/77972035
win32工程嵌入cef3
https://blog.csdn.net/lengyue2015/article/details/80807881
使用cookie实现自动登录功能
他的cefsimple这个demo是,默认的是没有cookie自动登录的。
只需要设置一下cache目录就可以了
demo中,就是在启动函数中设置一下 settings.root_cache_path 和 settings.cache_path
代码如下:
char szSubExePath[MAX_PATH];
PathCombineA(szSubExePath, szExeFullPath, "cef\\cache");
char szRootExePath[MAX_PATH];
PathCombineA(szRootExePath, szExeFullPath, "cef");
CefString(&settings.root_cache_path).FromASCII(szRootExePath);
CefString(&settings.cache_path).FromASCII(szSubExePath)
ps:关于cookies:
大多数需要登录的网站在用户验证成功之后都会设置一个 cookie,只要这个 cookie 存在并可以,用户就可以自由浏览这个网站的任意页面。
这个cookie 就是浏览器储存在用户电脑上的一小段文本文件。是纯文本格式,不包含任何可执行的代码。
一个 Web 页面或服务器来告知浏览器按照一定规范来储存这些信息,并在随后的请求中将这些信息发送至服务器,Web 服务器就可以使用这些信息来识别不同的用户。
ps:可能要以后有用的参考资料:
https://blog.csdn.net/lee353086/article/details/42970909?_t_t_t=0.22884619049948474 这个估计是自己设置cookie?但是也可以不自己设置,上面只要设置了root就自己设置了?
https://www.cnblogs.com/chechen/p/10286465.html CEF3中,CefCookieManager这个类就是用来管理cookies的。相关的函数有:https://magpcss.org/ceforum/apidocs3/projects/(default)/CefCookieManager.html 也可以直接看代码中的注释。
Method Summary | |
static CefRefPtr< CefCookieManager > | CreateManager( const CefString& path, bool persist_session_cookies, CefRefPtr< CefCompletionCallback > callback ) Creates a new cookie manager. |
virtual bool | DeleteCookies( const CefString& url, const CefString& cookie_name, CefRefPtr< CefDeleteCookiesCallback > callback )= 0 Delete all cookies that match the specified parameters. |
virtual bool | FlushStore( CefRefPtr< CefCompletionCallback > callback )= 0 Flush the backing store (if any) to disk. |
static CefRefPtr< CefCookieManager > | GetGlobalManager( CefRefPtr< CefCompletionCallback > callback ) Returns the global cookie manager. |
virtual bool | SetCookie( const CefString& url, const CefCookie& cookie, CefRefPtr< CefSetCookieCallback > callback )= 0 Sets a cookie given a valid URL and explicit user-provided cookie attributes. |
virtual bool | SetStoragePath( const CefString& path, bool persist_session_cookies, CefRefPtr< CefCompletionCallback > callback )= 0 Sets the directory path that will be used for storing cookie data. |
virtual void | SetSupportedSchemes( const std::vector< CefString >& schemes, CefRefPtr< CefCompletionCallback > callback )= 0 Set the schemes supported by this manager. |
virtual bool | VisitAllCookies( CefRefPtr< CefCookieVisitor > visitor )= 0 Visit all cookies on the IO thread. |
virtual bool | VisitUrlCookies( const CefString& url, bool includeHttpOnly, CefRefPtr< CefCookieVisitor > visitor )= 0 Visit a subset of cookies on the IO thread. |
https://www.cnblogs.com/llguanli/p/7198637.html 通过CefPostTask接口,进行设置和删除
CefPostTask(TID_IO, NewCefRunnableMethod(manager.get(), &CefCookieManager::SetCookie,CefString(domain.c_str()), cookie));
CefPostTask(TID_IO, NewCefRunnableMethod(manager.get(), &CefCookieManager::DeleteCookies, CefString(domain.c_str()), CefString("username")));
https://magpcss.org/ceforum/viewtopic.php?f=6&t=17793&hilit=cookie&start=0
CEF 获取Cookie例子 CefCookieManager C++ https://www.cnblogs.com/wcctml/p/6965349.html
https://stackoverflow.com/questions/1134290/cookies-on-localhost-with-explicit-domain