关于android webview session丢失问题
昨天碰到使用android webview发现session丢失的情况,刚开始网上搜了下也没发现需要的答案,最终在webvew的说明中找到了答案。问题主要出在webview与android的默认浏览器是部共享cookies等数据的,所以当webview跳转到默认浏览器页面后就感觉session丢失了。至于如何解决这个问题还有待查询,目前我知道了原因后是修改了程序的设计方法暂且绕开这个问题。以下是文档中对于webview关于cookies管理的说明。
Cookie and window management
For obvious security reasons, your application has its own cache, cookie store etc.—it does not share the Browser application's data.
By default, requests by the HTML to open new windows are ignored. This is true whether they be opened by JavaScript or by the target attribute on a link. You can customize yourWebChromeClientto provide your own behaviour for opening multiple windows, and render them in whatever manner you want.
The standard behavior for an Activity is to be destroyed and recreated when the device orientation or any other configuration changes. This will cause the WebView to reload the current page. If you don't want that, you can set your Activity to handle theorientationandkeyboardHiddenchanges, and then just leave the WebView alone. It'll automatically re-orient itself as appropriate. Read Handling Runtime Changes for more information about how to handle configuration changes during runtime.
下面是一些网友的参考资料
http://www.2cto.com/kf/201111/112387.html
http://developer.appcelerator.com/question/138788/android-cookies-set-by-default-browser
http://1995.xtown.org/?p=102001
http://stackoverflow.com/questions/5396965/setting-cookies-in-webview-android
http://stackoverflow.com/questions/2566485/webview-and-cookies-on-android