Original: Uncle also said Xamarin~android article ~ Native Landing and WebView website how to share session
The thing is, we recently opened an app, mainly using Xamarin to do a login, it with the server API data communication, when the user name password to go, jump to the new activity, and in the WebView control open the service side of the HTML5 page, and H5 page some need to be authorized to access, such as User Center, my order, my goods and so on, and our landing is implemented in the original activity, after the successful landing, the server will assign a sessionid to it, and stored in the client, as the next access to the identity, While using WebView to access the page, this SessionID and the previous is different, so, before the authorization is invalid, in order to solve this problem, we need to let the native and H5 site SessionID synchronization!
Login Activity Content
if(Msg. state = =" $") { varCCD =Newlist<string> (Response. Result.Headers.GetValues ("Set-cookie")); vararr = ccd[0]. Split (New Char[] {';'})[0]. Split (New Char[] {'='})[1]; Toast.maketext ( This,"sessionid="+arr, toastlength.short). Show (); Configdata.sessionid=arr; Intent Intent=NewIntent ( This,typeof(pageactivity)); StartActivity (Intent); }
The SessionID is then written to the corresponding domain name in the page activity.
Cookiesyncmanager.createinstance (this); = cookiemanager.instance; " asp.net_sessionid= " + Configdata.sessionid); var webView = findviewbyid<webview>(Resource.Id.webView); true ; Webview.loadurl (API); Webview.setwebviewclient (new custwebviewclient ());
In the above code, I define a global variable to hold the current SessionID
publicstaticclass configdata { publicstatic string Get Set ; } }
This object is static and the property is static, which means it is an object that will be initialized when the program starts!
Uncle also said Xamarin~android article ~ Native Landing and WebView website how to share session