Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Set and get Cookie in android Application

 
Satchidananda Mohanty
Ranch Hand
Posts: 78
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,


After wondering a lot I am not able to find the proper solution to set and get the cookies in an android application.
Kindly share your idea with some sample source code for the same. Any help would be greatly appreciated .

Thanks,
 
Tim Moores
Bartender
Posts: 2803
41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The HttpClient library- which is part of the Android API- can do that.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A cookie is just another HTTP header. You can always set it while making a HTTP call with the apache library or with HTTPUrlConnection. Either way you should be able to read and set HTTP cookies in this fashion.

More on making HTTP calls from android here -> http://android-developers.blogspot.in/2011/09/androids-http-clients.html
 
Satchidananda Mohanty
Ranch Hand
Posts: 78
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I want to set some variables to my application and which will be accessible all over the application. Just like session management in J2EE.
And gone through the above details and I do not have any url to set inside the code . If I'm wrong could you please post some sample codes for the same.

Thanks,
 
Tim Moores
Bartender
Posts: 2803
41
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So there's no HTTP involved at all? That means there'll be no cookie. For shared in-memory storage you may want to look into using an Applictaion class - http://www.google.de/search?q=android.app.Application
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic