Ad

PHP And WebView - Cookie Doesn't Are The Same

- 1 answer

I'm using a WebView to show a web application. All works, except one thing:

My login:

setcookie("USER_ID", $my_id, time() + 86400);

My logout:

setcookie("USER_ID", 0, time()-3600);
header('Location: ./index.php');

after that, i see the login page. And all is normal. The print_r of $_COOKIE array is:

Array
(
 [PHPSESSID] => e44ceefl92jvesh0kddmdicmv1
)

there isn't any USER_ID. and is all correct.

But if i close the Android Webview and reopen this app, magically I am logged in! And if I print the cookie Array, is:

Array
(
[USER_ID] => 1  // WTF?!?
[PHPSESSID] => e44ceefl92jvesh0kddmdicmv1
)

it seems like the android webview send to the server an older cookie array.

Please Help!

--------------------edit----------------

also if i print

cookieManager.getCookie("MyUrl");

there is the USER_ID cookie that i've deleted with logout

Ad

Answer

I tried to do this onPageFinished

CookieManager.getInstance().cookieManager.flush();

it seems to work, but i'm not sure

Ad
source: stackoverflow.com
Ad