[TIMOB-15434] Android: Cookies are not preserved after closing the app
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 3.1.2 |
Fix Version/s | n/a |
Components | Android |
Labels | android, cookies, httpclient |
Reporter | Fokke Zandbergen |
Assignee | Unknown |
Created | 2013-09-05T11:12:49.000+0000 |
Updated | 2020-08-18T20:42:48.000+0000 |
Description
On iOS any cookies set in HTTPClient sessions are kept until you or the server clears them. On Android though, they are cleared when you exit the app (not to the background, but really close it).
Create new app:
In
To reproduce
Create new app: titanium create -p ios,android -n testCookies -d . --id test.cookies
In app.js
use:
Ti.API.debug('I was just opened, not resumed');
var w = Ti.UI.createWindow({backgroundColor:'white'});
var b = Ti.UI.createButton({top: 100, title:'Request'});
var l = Ti.UI.createLabel({top: 200});
b.addEventListener('click', function () {
var client = Ti.Network.createHTTPClient({
onload: function(e) {
l.setText(this.responseText);
}
});
client.open('GET', 'http://dev.fokkezb.nl/cookie.php');
client.send();
});
w.add(b);
w.add(l);
w.open();
Run the app on both iOS and Android
Click the *Request* button several times
Confirm that under the button the server response is a incrementing number
Force close the app
Open the app again and click the *Request* button
You'll see that on iOS the number picks up where it was, but on Android is starts at 1 again
Server code
The PHP code on the server is really simple:
<?
session_start();
echo $_SESSION['count'] = (int) $_SESSION['count'] + 1;
?>
How did you close / killed the app in iOS?
I closed the app on iOS (7) by:
Singletap on the home button to move it to background.
Doubletap on the home button to bring up the new multitasking screen.
Swipe the app screen up to close it.
I've added a log call to the example code above so in the logs you can tell it's not resuming, but actually opening the app from scratch, still preserving the session and thus cookie.Issue reproduces Titanium SDK version 3.4.0 master, 3.1.2.GA Titanium Studio, build: 3.3.0.201407100905 Titanium Command-Line Interface CLI version 3.3.0, Android device : Motorola Moto G, Android version : 4.4.4
Any news on this issue?
I noticed that android get/addSystemCookie is not working on Android 6.1.0.GA. After some testing I found out that those functions were not working on previous versions either (5.4.1/6.0.4) but it was noticed now in 6.1.0.GA, because I suppose that cookies were auto synced with the webview and in 6.1.0.GA cookies are not available after you restart the app I also added this comment on TIMOB-20075. I see 3 related tickets all going back to older versions, I am not sure if this should be a new ticket for 6.1.0.GA