Cookies and Webviews again
How do I make a cookie obtained via an httpclient request get used in a subsequent webview?
A previous 'answer' merely stated that the respondent had found a way to enter the cookies into a webview.db by reading the older support forums.
These are no longer available, there is of course nothing in the documentation, can anybody tell me anything about a webview database?
Thanks,
JH
2 Answers
-
10 months later, same question.
How to manually set a cookie for a given host for WebView? -
i am also struggling with this (the original question) using android. not the webview database part, but attempting to use a xhr cookie in a webview. this is what i have done so far:
in my xhr.onload:
Ti.App.my_cookie = xhr.getResponseHeader("Set-Cookie");
then in webview.beforeload:
webview.evalJS("document.cookie="+Ti.App.my_cookie+";");
but it always hangs on setting the cookie, showing a line like this in the android emulator log:
D/TiWebViewBinding( 1369): (main) [4,5966] getJSValue:javascript:_TiReturn.setValue((function(){try{return document.cookie=cookie_monster=blahblah; path=/; HttpOnly;+"";}catch(ti_eval_err){return '';}})());
i am not sure where the
;+"";
in the log comes from, and maybe that is messing stuff up, but if i set it to an empty cookie (
evalJS("document.cookie=")
) it doesn't hang and shows a log with:{try{return document.cookie+"";}
and the cookie is empty.
so… more of another question than an answer, is this not working the way it's supposed to, or am i doing something wrong?