Quantcast
Viewing all articles
Browse latest Browse all 8068

persist cookie in webview

Am using 3.1.3.GA sdk, Alloys 1.2.2 and 2.3.3 Android Emulator. In app, I am persisting the login of the user and for some reason I need to access site url in webview, there am unable to persist session. My code,

web.xml

<Alloy>
    <Window id="webWindow">
        <WebView id="webV" url="http://somesite"></WebView>
    </Window>
</Alloy>
web.js
var win = $.webWindow;
var view = $.webV;
 
function setCookie(){
    var cookies = Ti.App.Properties.getString('appCredentials', null);
    if(cookies){
        view.evalJS("document.cookie=\"" + cookies + "\";");
    }
}
 
function showCookie(){
    var cookies = view.evalJS("document.cookie");
    Ti.API.info(view.url+'--'+cookies);
}
 
function closeWindow(){
    win.close();
}
 
view.addEventListener('beforeload', setCookie);
view.addEventListener('load', showCookie);
Is this correct way to set cookies, I tested in Emulator and also in Karbonn mobile(4.0 Android).

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>