All Projects → franmontiel → Persistentcookiejar

franmontiel / Persistentcookiejar

Licence: apache-2.0
A persistent CookieJar implementation for OkHttp 3 based on SharedPreferences.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Persistentcookiejar

Mern Login Signup Component
Minimalistic Sessions based Authentication app 🔒 using Reactjs, Nodejs, Express, MongoDB and Bootstrap. Uses Cookies 🍪
Stars: ✭ 74 (-95.68%)
Mutual labels:  cookies
Neteasecloudmusic Mvvm
Jetpack MVVM最佳实践 - 重构仿网易云音乐安卓客户端
Stars: ✭ 103 (-93.99%)
Mutual labels:  okhttp3
Novate
A safety client by Https for android, (Android网络框架,基于Retrofit和RxJava打造的链式网络库, 支持okhttp的调用风格,又兼容Retrofit API,并支持rxJava链式操作)
Stars: ✭ 1,442 (-15.87%)
Mutual labels:  okhttp3
Authenticationintro
Stars: ✭ 82 (-95.22%)
Mutual labels:  cookies
Todo
简洁清爽的Todo清单工具❤️ (MVP+okhttp3+retrofit+gson)
Stars: ✭ 93 (-94.57%)
Mutual labels:  okhttp3
Sessionup
Straightforward HTTP session management
Stars: ✭ 107 (-93.76%)
Mutual labels:  cookies
Theming Demo
https://codesandbox.io/s/github/juliaqiuxy/theming-demo/tree/master/?from-embed
Stars: ✭ 59 (-96.56%)
Mutual labels:  cookies
Chucker
🔎 An HTTP inspector for Android & OkHTTP (like Charles but on device)
Stars: ✭ 2,169 (+26.55%)
Mutual labels:  okhttp3
Yourweather
🌞 你的天气:OkHttp +Material Design+《第一行代码》
Stars: ✭ 100 (-94.17%)
Mutual labels:  okhttp3
Ember Cookies
Cookies abstraction for Ember.js that works both in the browser as well as with Fastboot on the server
Stars: ✭ 109 (-93.64%)
Mutual labels:  cookies
Newspaper
An aggregated newspaper app containing news from 10+ local news publishers in Hong Kong. Made with ❤
Stars: ✭ 82 (-95.22%)
Mutual labels:  okhttp3
Okhttps
如艺术一般优雅,像 1、2、3 一样简单,前后端通用,轻量却强大的 HTTP 客户端(同时支持 WebSocket 与 Stomp 协议)
Stars: ✭ 92 (-94.63%)
Mutual labels:  okhttp3
Requests
A simple, yet elegant, HTTP library.
Stars: ✭ 46,558 (+2616.34%)
Mutual labels:  cookies
Spider
Monitor and modify network requests
Stars: ✭ 78 (-95.45%)
Mutual labels:  okhttp3
Livedata Call Adapter
A simple LiveData call adapter for retrofit
Stars: ✭ 119 (-93.06%)
Mutual labels:  okhttp3
Api Debugger
🔨A like Postman API debugger that supports custom encryption. 一个类似Postman的支持自定义加密传输的后台API接口调试工具.
Stars: ✭ 63 (-96.32%)
Mutual labels:  okhttp3
Ihavecookies
jQuery plugin to display cookie consent message (EU regulation)
Stars: ✭ 106 (-93.82%)
Mutual labels:  cookies
Py3 Pinterest
Fully fledged Python Pinterest client
Stars: ✭ 133 (-92.24%)
Mutual labels:  cookies
Android Cnblogs
🔥🔥 博客园Android端开源项目,界面简洁清新。
Stars: ✭ 127 (-92.59%)
Mutual labels:  okhttp3
Rxapp
Stars: ✭ 108 (-93.7%)
Mutual labels:  okhttp3

PersistentCookieJar for OkHttp 3

A persistent CookieJar implementation for OkHttp 3 based on SharedPreferences.

If you're looking for a OkHttp 2/HTTPUrlConnection persistent CookieStore it can be found at this Gist.

Download

Step 1. Add the JitPack repository in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Step 2. Add the dependency

dependencies {
    compile 'com.github.franmontiel:PersistentCookieJar:v1.0.1'
}

Usage

Create an instance of PersistentCookieJar passing a CookieCache and a CookiePersistor:

ClearableCookieJar cookieJar =
                new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(context));

Then just add the CookieJar when building your OkHttp client:

OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .cookieJar(cookieJar)
                .build();

Features

This is a really simple library but here are some of the things that it provides:

  • Possibility to clear the jar: PersistentCookieJar implements ClearableCookieJar interface that declares a clear() method for removing all cookies from the jar.

  • Possibility to clear session cookies: PersistentCookieJar implements ClearableCookieJar interface that declares a clearSession() method for removing session cookies from the jar.

  • Decoupled and extensible: CookieCache and CookiePersistor are interfaces so you can provide your own implementation for each one.

    • CookieCache represents an in-memory cookie storage. SetCookieCache is the provided implementation that uses a Set to store the Cookies.
    • CookiePersistor represents a persistent storage. SharedPrefsCookiePersistor is the provided implementation that uses a SharedPreferences to persist the Cookies.
  • Thread-safe: PersistentCookieJar public methods are synchronized so there is no need to worry about threading if you need to implement a CookieCache or a CookiePersistor.

ProGuard

The following configuration is only needed for version 0.9.2 and below:

-dontwarn com.franmontiel.persistentcookiejar.**
-keep class com.franmontiel.persistentcookiejar.**

-keepclassmembers class * implements java.io.Serializable {  
    static final long serialVersionUID;  
    private static final java.io.ObjectStreamField[] serialPersistentFields;  
    !static !transient <fields>;  
    private void writeObject(java.io.ObjectOutputStream);  
    private void readObject(java.io.ObjectInputStream);  
    java.lang.Object writeReplace();  
    java.lang.Object readResolve();  
}

License

Copyright 2016 Francisco José Montiel Navarro

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].