engine.loadUrl("file:///android_asset/" + page);
I have found when the exact same file is loaded from the web (i.e. http://www.domain.com/index.html) then same file can set the cookie as expected.
Older versions of android do allow the creation of cookies on local files, but newer versions do not. I have tested this and it works on Samsung Galaxy Ace, HTC Desire Z and eclipse emulators of lower SDK, but does not work on Samsung SIII nor Samsung Tab 10.1.
I need to set a cookie in order to carry data between pages in my webview; saving search results to be re-displayed.
If anyone knows of any methods/hacks to get around these local file problem I'd really reeeally appreciate it. I've been at this for about 8 weeks now. I asked a simular question which may be helpful for further reading, but the problem has now been identified and is very much a different question so I'm asking this here. Android webview cookie returns null
The reason this is not possible is down to a security limitation of implementing cookies over localhost. If cookie setting were possible, then it would also be possible for others to create apps and read your apps cookies. It used to be possible on early versions of Android, but the security hole was later patched.
This is why the same limitation exists on conventional web browsers.
See this related question and answer: Android webview cookie returns null