Skip to content

Commit 023e6f1

Browse files
committed
Fix logout bug
There's a Cloudflare cookie with a 30 min expiry, and our cookie code was including those when calculating the expiry date for the actual site cookies (which are like a year). Now it doesn't do that
1 parent 8839bad commit 023e6f1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Awful.apk/src/main/java/com/ferg/awfulapp/network/CookieController.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ public static synchronized boolean saveLoginCookies(Context ctx) {
153153
Date expires = null;
154154
Integer version = null;
155155

156+
Timber.d("Saving cookies - here's what we got:");
157+
logCookies();
158+
156159
for (HttpCookie cookie : cookieManager.getCookieStore().get(uri)) {
157160
switch (cookie.getName()) {
158161
case Constants.COOKIE_NAME_USERID:
@@ -167,6 +170,9 @@ public static synchronized boolean saveLoginCookies(Context ctx) {
167170
case Constants.COOKIE_NAME_SESSIONHASH:
168171
sessionHash = cookie.getValue();
169172
break;
173+
default:
174+
// unrecognised cookie, ignore it! some cloudflare ones have a real short expiry
175+
continue;
170176
}
171177

172178
// keep the soonest valid expiry in case they don't match
@@ -196,6 +202,7 @@ public static synchronized boolean saveLoginCookies(Context ctx) {
196202
edit.putString(Constants.COOKIE_PREF_SESSIONHASH, sessionHash);
197203
}
198204
if (expires != null) {
205+
Timber.i("Storing login cookie, expires: %s", expires.toString());
199206
edit.putLong(Constants.COOKIE_PREF_EXPIRY_DATE, expires.getTime());
200207
}
201208
edit.putInt(Constants.COOKIE_PREF_VERSION, version);
@@ -218,7 +225,8 @@ public static void logCookies() {
218225
Timber.i("---BEGIN COOKIE DUMP---");
219226
List<HttpCookie> cookies = cookieManager.getCookieStore().getCookies();
220227
for (HttpCookie c : cookies) {
221-
Timber.i(c.toString());
228+
Timber.d("Name: %s\nSecure only: %b, expired: %b, max age: %d\nContent: %s\n",
229+
c.getName(), c.getSecure(), c.hasExpired(), c.getMaxAge(), c.toString());
222230
}
223231
Timber.i("---END COOKIE DUMP---");
224232
}

0 commit comments

Comments
 (0)