0% found this document useful (0 votes)
2K views

How To Enable Cookies in Android Webview - Stack Overflow PDF

The document discusses how to enable cookies in a specific Android webview when multiple webviews are used on a single activity. The CookieManager class enables cookies for all webviews by default, so the key is to initialize the target webview before enabling cookies via CookieManager. Calling CookieManager.setAcceptCookie(true) after initializing the target webview will enable cookies only for that webview.

Uploaded by

Shoaib Quraishi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

How To Enable Cookies in Android Webview - Stack Overflow PDF

The document discusses how to enable cookies in a specific Android webview when multiple webviews are used on a single activity. The CookieManager class enables cookies for all webviews by default, so the key is to initialize the target webview before enabling cookies via CookieManager. Calling CookieManager.setAcceptCookie(true) after initializing the target webview will enable cookies only for that webview.

Uploaded by

Shoaib Quraishi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

sign up

Stack Overflow

log in

Questions Tags Users Badges Unanswered Ask

Read this post in our app!

How to enable cookies in android webview?

13

android

webview

how do i enable cookies in a webview?


i tried to use
CookieManager.getInstance().setAcceptCookie(true);

just before calling WebView.loadUrl() and it doesnt work as i get a html page error from a website saying cookies need to be enabled.
What i dont understand is how does cookieManager know which webview to enable cookies?
say if i had a activity with two webviews in the screen and i only wanted one of those webviews to enable cookies, how is that possible using a
CookieManager?
i feel like i am missing something? i could not find a method like webView.setCookieManager or Cookiemanager.setWebView(webview)
Thanks
share

improve this question


jonney
4,398 30 77 130

1 Answer

16

Asked
Jun 21 '13 at 8:28

Order By

Votes

CookieManager.getInstance() is the CookieManager instance for your entire application. Hence, you enable or disable cookies for all the webviews in

your application.

Normally it should work if your webview is already initialized:


http://developer.android.com/reference/android/webkit/CookieManager.html#getInstance()
Maybe you call CookieManager.getInstance().setAcceptCookie(true); before you initialize your webview and this is the problem?
share

improve this answer


Integrating Stuff
3,263 1 18 29

Answered
Jun 21 '13 at 8:33

Francisco Corrales Morales


1,455 16 38

Edited
May 26 '14 at 2:45

cheers. works now after executing the code after i loadUrl jonney Jun 21 '13 at 9:26
My problem is that the webview does not send the cookie already living in the store. How do you make webview send the cookie? I am initializing webview after
CookieManager.getInstance().setAcceptCookie(true); Am I missing something? kalehv Aug 18 '15 at 16:19
add a comment

Your Answer

log in
or

Name

Email

By posting your answer, you agree to the privacy policy and terms of service.

Post Your Answer

meta chat tour help blog privacy policy legal contact us full site
Download the Stack Exchange Android app
2016 Stack Exchange, Inc

You might also like