Android JQuery mobile cookies not stored
I am using JQuery mobile library with jquery.cookie.js on Android. The header of index.html looks like this:
<link rel="stylesheet" href="css-js/jquery.mobile-1.0a2.min.css" />
<script src="css-js/jquery-1.4.4.min.js"></script>
<script src="css-js/jquery.mobile-1.0a2.min.js"></script>
<script src="css-js/jquery.cookie.js"></script>
<script src="css-js/jquery.ba-dotimeout.js"></script>
Everything else works except storing and retrieving cookies.
The code to store them looks like
var tmp = 'abc'
$.cookie(COOKIE_NAME, tmp);
The code to retrieve looks like
var stored = $.co开发者_开发技巧okie(COOKIE_NAME)
And i'm sure there are no empty or null values added. I have set
mWebView.getSettings().setDomStorageEnabled(true);
for the WebView.
What could be the problem, or what could be a good way to debug it?
The issue may be related to the fact that you are not setting a path:
$.cookie(COOKIE_NAME, tmp, { path: '/' });
Without the path, I believe the browser defaults to the current path (whatever page you are on), and as soon as you go to another page, the cookie is unaccessable.
精彩评论