Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-20229] Android: WebView and Cookie fix #7706

Merged
merged 3 commits into from Feb 26, 2016

Conversation

ashcoding
Copy link
Contributor

Jira: https://jira.appcelerator.org/browse/TIMOB-20229

Test code:-

var win = Ti.UI.createWindow({
    layout : 'vertical'
});
var url = 'http://www.appcelerator.com/'; //Or any html file
var reload = Ti.UI.createButton({
    title : 'reload',
    height : 50,
    width : 100,
    top : 5,
});

reload.addEventListener('click', function() {
    web.url = url;
});

win.add(reload);

var web = Ti.UI.createWebView({
    url : url,
    width : Ti.UI.FILL,
    top : 100,
    height : Ti.UI.FILL,

});

win.add(web);
var i = 1;

web.addEventListener('load', function(e) {

    var d = new Date();
    d.setTime(d.getTime() + (2 * 24 * 60 * 60 * 1000));

    var cookie = Ti.Network.createCookie({
        name : 'helloWorld',
        domain : url,
        value : "testCookie",
        expiryDate : d,

    });

    Ti.Network.addSystemCookie(cookie, web);
    Ti.API.info("createCookie -> " + JSON.stringify(cookie));

    var cookies = Ti.Network.getSystemCookies(url,null,null);

    if(cookies != null) {
        Ti.API.info("# of cookies -> " + cookies.length);
        for ( i = 0; i <= cookies.length - 1; i++) {
            Ti.API.info("cookie -> " + cookies[i].name + " - " + cookies[i].value);
        }
    }

});

win.open();

@ashcoding
Copy link
Contributor Author

The domain seems to be the one causing the code not to work in the cookieString. The domain is already used to set the cookieString, thus, there is no need to use it twice.

@hieupham007
Copy link
Contributor

Please merge with master

@ashcoding
Copy link
Contributor Author

Master merged.

@hieupham007
Copy link
Contributor

Code reviewed and funtionally tested. Looks good

hieupham007 added a commit that referenced this pull request Feb 26, 2016
[TIMOB-20229] Android: WebView and Cookie fix
@hieupham007 hieupham007 merged commit 230c9fe into tidev:master Feb 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants