• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cookies in Android Apps

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an app that has to go out to a webpage to create a userid. The userid is checked and then the user is sent to the next page. A cookie is passed back to the web browser to carry the information forward. However, in android, the cookie does not get passed to the next page. I've tried using the builtin web view, but each 'page' is treated as a separate web instance and doesn't pass the cookie to the next page. I've tried passing the user to the android browser, but that doesn't seem to work either.

The documentation in this area is not very good. Can you suggest a strategy to get the cookie and pass it to the next page?

Thanks,

Ed
 
Ranch Hand
Posts: 136
Android Mac Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Ed,

There are classes available in Android to store & set cookies.
Have you gone through CookieManager ?
Hope it will help you.

Thanks & Regards
Pratik Goswami
 
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ed, would you please clarify your setup? How do you "go out to a webpage to create a userid"? How is the user "sent to the next page"?

Also, you mention the web browser and a WebView. How are you using the Browser activity, and how are you using a WebView?
 
Ed Mahoney
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for not being more specific

Here is the code I use to launch the webview, this is an activity. This does display the proper page, but when the user clicks the link on that page, no cookie is sent to the server. My understanding is that the shouldOverrideURLLoading shuold keep the user in the same view and not create a new one. Is there something else I have to do?

Thanks,
ed



WebView webview = new WebView(this);

webview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
setContentView(webview);
webview.loadUrl(my url here);
 
Daniel Trebbien
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using two activities (one for showing the WebView that the user uses to log in, another for showing a WebView to display pages that require authentication)?

I am experimenting with:

where session.php on 192.168.1.100 is:



PHP uses cookies for sessions, so because I see the same session ID between page refreshes, I know that the WebView is sending the PHPSESSID cookie.

It seems to be working fine.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic