Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling Session Cookie in Android Volley

For those unfamilar with Volley its a networking library and,it will switch its http request client from HttpUrlConnection or HttpClient depending on android version, so one thing I need to know is how to add cookie support to each of these client types. How do I opt in to session management for both types of clients?

I have seen this solution: Using cookies with Android volley library

which is a good step in the right direction. Has anyone found a way to push this logic a level down into the library without using preferences? or references from Volley into the application. I don't mind rewriting the Volley helper class to apply some support for this but not sure if both types of http clients support cookies and what exactly I would need to do to turn on cookie support?

also is there a way to use Volley with CookieManager perhaps?

like image 538
TestBest Avatar asked Aug 24 '13 00:08

TestBest


2 Answers

Take a look at my answer on the other question you linked. By specifying the HttpClient for Volley to use, it will only ever use that one for connections. Thus obviating the need to set cookies on both.

like image 95
Adam Avatar answered Nov 22 '22 20:11

Adam


For handling session cookies, I use CookieManager and a own implementation of CookieStore. Here I show a implementation of this, storing the cookie in SharedPreferences

like image 22
Lukas Avatar answered Nov 22 '22 20:11

Lukas