当前位置:网站首页>Research on cookies in WebView
Research on cookies in WebView
2022-07-28 23:06:00 【ZZ White Dragon】
1.webview cookie Keep it locally
Project use WebView In fact, it will automatically Cookie Save in local database . The path to save is data/data/package_name/app_WebView/Cookies Though not .db At the end of the , It's actually a .db file , If the validity period is not set , Unless websid,sid Replace , It won't fail
2.webview Medium cookie It will not be cleared as the page closes
conversation cookie stay WebView It will not expire when closed , You have to manage it yourself .
Turn on cookie
if (android.os.Build.VERSION.SDK_INT >= 21) {
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
} else {
CookieManager.getInstance().setAcceptCookie(true);
}
1. Set up cookie:
In the parameter URL In the process of use, it is basically the domain name . for example https://www.baidu.com/ You can make www.baidu.com
Cookie The acquisition of the list varies according to the storage method of your own items . For example, using SharedPreferences and HashMap
Pay attention to for loop Conduct setCookie(String url, String value) call . There are blogs on the Internet that use semicolons to splice manually value Values can cause Cookie Cannot be set completely or invalid
Be careful value The value of is to use key=value The complete form of . Document tips the cookie as a string, using the format of the ‘Set-Cookie’ HTTP response header
CookieSyncManager Is an obsolete class ,Api21 in WebView Can automatically synchronize .
CookieSyncManager.getInstance().sync(); An alternative to this method is cookieManager.flush();
Cookie The synchronization method should be in WebView Of setting After set up, call , Otherwise it will not work .
call loadUrl(url); The previous sentence calls this method to Cookie Synchronous operation .
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setCookie(murl, “username=” + nickName + “;”);//cookies Is in HttpClient From cookie
cookieManager.setCookie(murl, “websid=” + currentUser.getSid() + “;”);//cookies Is in HttpClient From cookie
cookieManager.setCookie(murl, “sid=” + currentUser.getSid() + “;”);//cookies Is in HttpClient From cookie
cookieManager.setCookie(murl, “userid=” + currentUser.getId() + “;”);//cookies Is in HttpClient From cookie
cookieManager.setCookie(murl, “t3kwid=” + currentUser.getId() + “;”);//cookies Is in HttpClient From cookie
cookieManager.setCookie(murl, “uph=” + “;”);//cookies Is in HttpClient From cookie
CookieSyncManager.getInstance().sync();
2. Sync cookie:
public void onPageFinished(WebView view, String url) {
CookieManager cookieManager = CookieManager.getInstance();
String cookieStr = cookieManager.getCookie(url);
String[] split = cookieStr.split(";");
}
3. eliminate cookie
CookieManager cookieManagerStore = CookieManager.getInstance();
cookieManagerStore.removeAllCookie();
边栏推荐
- The safety dog has been selected into many details of cloud security panorama 2.0
- [database]
- (重要)初识C语言 -- 函数
- Learning experience sharing 3: yolov5 training data set path index
- Learning experience sharing 5: yolov5 dataset division and Yolo format conversion
- 赋能中国芯创业者!看摩尔精英如何破解中小芯片企业发展难题
- Summary of the problem that MathType formula does not correspond in word
- OSV_ q The size of tensor a (704) must match the size of tensor b (320) at non-singleton dime
- Multi activity disaster recovery construction after 713 failure of station B | takintalks share
- RouYi-Cloud平台 ---项目的启动、登录功能是怎么实现的、怎么样创建新模块
猜你喜欢

xshell7,xftp7个人免费版官方下载,无需破解,免激活,下载即可使用

Migration from IPv4 to IPv6

Summary of common formula notes for solving problems in Higher Mathematics

MySQL常用的日期时间函数

《Shortening passengers’ travel time A dynamic metro train scheduling approach using deep reinforcem》

Target detection notes - overview and common data sets

The safety dog has been selected into many details of cloud security panorama 2.0
![[radar] radar signal online sorting based on kernel clustering with matlab code](/img/56/1f8e8690b47fc4a1f101d4e530b87f.png)
[radar] radar signal online sorting based on kernel clustering with matlab code

CGLIb 创建代理

A new MPLS note from quigo, which must be read when taking the IE exam ---- quigo of Shangwen network
随机推荐
Is 1E3 a floating point number?
高等数学解题常用公式笔记总结
Target detection notes fast r-cnn
leetcode 199. 二叉树的右视图
No code development platform management background tutorial
[copy] Internet terms, abbreviations, abbreviations
Target detection notes -yolo
OSV-q The size of tensor a (3) must match the size of tensor b (320) at non-singleton dimension 3
MySQL Basics - Introduction and basic instructions
投资1450亿欧元!欧盟17国宣布联合发展半导体技术
Improvement 14 of yolov5: replace the backbone network C3 with the lightweight network GhostNet
Nacos配置热更新的4种方式、读取项目配置文件的多种方式,@value,@RefreshScope,@NacosConfigurationProperties
18 diagrams, intuitive understanding of neural networks, manifolds and topologies
Console.log() console display... Solution
Thesis reading (3) - googlenet of classification
《Shortening passengers’ travel time A dynamic metro train scheduling approach using deep reinforcem》
Invest 50billion yuan! SMIC capital was officially registered!
sql优化常用的几种方法
[filter tracking] target tracking based on EKF, TDOA and frequency difference positioning with matlab code
The simple neural network model based on full connection layer MLP is changed to the model based on CNN convolutional neural network