当前位置:网站首页>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();
边栏推荐
- 高等数学解题常用公式笔记总结
- MySQL foundation - advanced functions
- pg_ Installation and use of RMAN "PostgreSQL"
- 一种分布式深度学习编程新范式:Global Tensor
- 【MongoDB】MongoDB数据库的基础使用,特殊情况以及Mongoose的安装和创建流程(含有Mongoose固定版本安装)
- Console.log() console display... Solution
- 【滤波跟踪】基于EKF、时差和频差定位实现目标跟踪附matlab代码
- Target detection notes fast r-cnn
- Hbuilderx shortcut key
- Improvement 16 of yolov5: replace backbone network C3 with lightweight network pp-lcnet
猜你喜欢

frontiers出版社投稿记录(附状态变化)

Cglib create proxy

Thesis reading (1) - zfnet of classification

Sqlilabs-1 (breakthrough record)

Submission records of frontiers Publishing House (with status changes)

Reading of "robust and communication efficient federated learning from non-i.i.d. data"

LTE cell search process and sch/bch design

After reading MySQL database advanced practice (SQL xiaoxuzhu)

MySQL foundation - data query

There are four ways for Nacos to configure hot updates and multiple ways to read project configuration files, @value, @refreshscope, @nacosconfigurationproperties
随机推荐
cnpm安装步骤
定了!哪吒S全系产品将于7月31日上市发售
[physical application] atmospheric absorption loss with matlab code
Invest 145billion euros! EU 17 countries announce joint development of semiconductor technology
Reading of "robust and communication efficient federated learning from non-i.i.d. data"
轮子六:QSerialPort 串口数据 收发
【数据库】
Seagate released a new risc-v architecture processor: the performance of mechanical hard disk soared 3 times
Is 1E3 a floating point number?
A simple neural network model based on MLP full connection layer
Will Qualcomm and MediaTek chips soon be sold, and will they surpass Huawei to become the first in China?
can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to host memory
安全狗入选《云安全全景图2.0》多个细项
Nacos配置热更新的4种方式、读取项目配置文件的多种方式,@value,@RefreshScope,@NacosConfigurationProperties
There are four ways for Nacos to configure hot updates and multiple ways to read project configuration files, @value, @refreshscope, @nacosconfigurationproperties
Migration from IPv4 to IPv6
Es learning directory
(important) first knowledge of C language -- function
[3D target detection] 3dssd (I)
MySQL Basics - Introduction and basic instructions