Handling Session Cookie in Android Volley
Asked Answered
C

2

9

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?

Caves answered 24/8, 2013 at 0:50 Comment(1)
Comments anyone? Cookies/Tokens are often used in rest api's and it makes sense to discuss how to add custom tokens to headers and where these should be kept.Caves
S
3

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.

Speechless answered 21/1, 2014 at 23:54 Comment(0)
S
1

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

Sedation answered 19/8, 2014 at 20:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.