登录到应用程序后,我想要自动登录网络视图,但我有一个cookie,但似乎设置的cookie根本不起作用,我从邮递员那里获取了cookie
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@SuppressLint("SetJavaScriptEnabled")
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//Todo WebView Deer Site Duudah Cookie Beldeed auto Login hiih\
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.screendrawlayout, container, false);
ButterKnife.bind(this, view);
String myUrl = Utils.getUrl(Objects.requireNonNull(getContext())) + "/main.php?p=ZGj9cw==&lisMod=cGhxbg==&lisId=" + docId;
WebSettings webSettings = webview.getSettings();
webSettings.setLoadWithOverviewMode(true);
webSettings.setUseWideViewPort(true);
webview.getSettings().setJavaScriptEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.setAcceptThirdPartyCookies(webview, true);
}
"PHPSESSID=7viho8qqb3esgja6pled5gg2h6; path=/; HttpOnly");
cookieManager.setCookie(myUrl, "PHPSESSID=7viho8qqb3esgja6pled5gg2h6; path=/; HttpOnly");
cookieSyncManager.sync();
webview.loadUrl(myUrl);
return view;
}