0
我想設置會話CoockieAndroid WebView設置Cookie失敗(sessionCookie)
我在WebView中設置Cookie有問題。這是代碼:
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState){
View v = inflater.inflate(R.layout.fragment_web, parent, false);
String co = GlobalSession.SESSION_ID; //m4mg2aleunei8fad1lvn8h6n67
String co_name = GlobalSession.COOKIE_NAME; //PHPSESSID
//set and load web View
CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(getActivity());
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.removeSessionCookie();
cookieManager.setCookie("192.168.70.103", GlobalSession.SESSION_ID);
cookieSyncManager.sync();
WebView mView = new WebView(getActivity());
mView = (WebView) v.findViewById(R.id.web_view);
mView.getSettings().setJavaScriptEnabled(true);
mView.setWebViewClient(new myWebViewClient());
mView.loadUrl("http://192.168.70.103/test.php");
return v;
}
在上一步中我發送的用戶名和傳遞給服務器,這對我與參數,如SESSSION_ID和COOKIE_NAME迴應...在test.php的
我驗證用戶被盯上....好吧,不,所以我認爲設置cookie失敗。 如何正確設置cookie是我的問題。