A session is a sequence of requests made by a single end-user during a visit to a particular site. A session or query session may be all queries made by a user in a particular time period or it may also be a series of queries or navigation with a consistent underlying user need.
In Android, if we use the retrofit for web services call it internally uses OkHttp and OkHttp does not keep the track of session automatically. Generally, the session is maintained using the cookie value that we get in each response we receive.
So, we need to keep the cookie from one call to another. this can be down using CookieManager as follows:
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
CookieHandler cookieHandler = new CookieManager();
OkHttpClient client = new OkHttpClient.Builder().addNetworkInterceptor(interceptor)
Retrofit retrofit = new Retrofit.Builder()
for this following dependencies are required: