react-native-cookies / Cookies

Licence: mit
🍪 Cookie Manager for React Native

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Cookies

Hzdtf.foundation.framework
基础框架系统,支持.NET和.NET Core平台,语言:C#,DB支持MySql和SqlServer,主要功能有抽象持久化、服务层,将业务基本的增删改查抽离复用;提供代码生成器从DB生成实体、持久化、服务以及MVC控制器,每层依赖接口,并需要在客户端将对应实现层用Autofac程序集依赖注入,用AOP提供日志跟踪、事务、模型验证等。对Autofac、Redis、RabbitMQ封装扩展;DB访问提供自动主从访问,Redis客户端分区。特别适合管理系统。
Stars: ✭ 22 (-89.47%)
Mutual labels:  cookies
Sessionup
Straightforward HTTP session management
Stars: ✭ 107 (-48.8%)
Mutual labels:  cookies
Next Firebase Auth
Simple Firebase authentication for all Next.js rendering strategies
Stars: ✭ 135 (-35.41%)
Mutual labels:  cookies
Dragon
⚡A powerful HTTP router and URL matcher for building Deno web servers.
Stars: ✭ 56 (-73.21%)
Mutual labels:  cookies
Authenticationintro
Stars: ✭ 82 (-60.77%)
Mutual labels:  cookies
Ember Cookies
Cookies abstraction for Ember.js that works both in the browser as well as with Fastboot on the server
Stars: ✭ 109 (-47.85%)
Mutual labels:  cookies
Gdpr rails
Rails Engine for the GDPR compliance
Stars: ✭ 580 (+177.51%)
Mutual labels:  cookies
Privacybadger
Privacy Badger is a browser extension that automatically learns to block invisible trackers.
Stars: ✭ 2,346 (+1022.49%)
Mutual labels:  cookies
Ihavecookies
jQuery plugin to display cookie consent message (EU regulation)
Stars: ✭ 106 (-49.28%)
Mutual labels:  cookies
Next Dark Mode
🌑 Enable dark mode for Next.js apps
Stars: ✭ 133 (-36.36%)
Mutual labels:  cookies
Cookies
Signed and unsigned cookies based on Keygrip
Stars: ✭ 1,090 (+421.53%)
Mutual labels:  cookies
Mern Login Signup Component
Minimalistic Sessions based Authentication app 🔒 using Reactjs, Nodejs, Express, MongoDB and Bootstrap. Uses Cookies 🍪
Stars: ✭ 74 (-64.59%)
Mutual labels:  cookies
Py3 Pinterest
Fully fledged Python Pinterest client
Stars: ✭ 133 (-36.36%)
Mutual labels:  cookies
Cookie Autodelete
Firefox and Chrome WebExtension that deletes cookies and other browsing site data as soon as the tab closes, domain changes, browser restarts, or a combination of those events.
Stars: ✭ 1,015 (+385.65%)
Mutual labels:  cookies
Ngx Store
Angular decorators to automagically keep variables in HTML5 LocalStorage, SessionStorage, cookies; injectable services for managing and listening to data changes and a bit more.
Stars: ✭ 152 (-27.27%)
Mutual labels:  cookies
React Native Cookies
Cookie manager for React Native
Stars: ✭ 784 (+275.12%)
Mutual labels:  cookies
Requests
A simple, yet elegant, HTTP library.
Stars: ✭ 46,558 (+22176.56%)
Mutual labels:  cookies
Supra Api Nodejs
❤️ Node.js REST API boilerplate
Stars: ✭ 182 (-12.92%)
Mutual labels:  cookies
Vue Warehouse
A Cross-browser storage for Vue.js and Nuxt.js, with plugins support and easy extensibility based on Store.js.
Stars: ✭ 161 (-22.97%)
Mutual labels:  cookies
Persistentcookiejar
A persistent CookieJar implementation for OkHttp 3 based on SharedPreferences.
Stars: ✭ 1,714 (+720.1%)
Mutual labels:  cookies

React Native Cookies - A Cookie Manager for React Native

Cookie Manager for React Native

chat on Discord

This module was ported from joeferraro/react-native-cookies. This would not exist without the work of the original author, Joe Ferraro.

Important notices & Breaking Changes

  • v6.0.0: Package name updated to @react-native-cookies/cookies.
  • v5.0.0: Peer Dependency of >= React Native 0.60.2
  • v4.0.0: Android SDK version bumpted to 21
  • v3.0.0: Remove React Native Core dependencies, CookieManager.set() support for Android
  • v2.0.0: Package name updated to @react-native-community/cookies.

Maintainers

Platforms Supported

✅ iOS
✅ Android
❌ Expo is working on their own cookie support (https://github.com/expo/expo/issues/6756)

Currently lacking support for Windows, macOS, and web. Support for these platforms will be created when there is a need for them. Starts with a posted issue.

Installation

yarn add @react-native-cookies/cookies

Then link the native iOS package

npx pod-install

Usage

A cookie object can have one of the following fields:

export interface Cookie {
  name: string;
  value: string;
  path?: string;
  domain?: string;
  version?: string;
  expires?: string;
  secure?: boolean;
  httpOnly?: boolean;
}

export interface Cookies {
  [key: string]: Cookie;
}
import CookieManager from '@react-native-cookies/cookies';

// set a cookie
CookieManager.set('http://example.com', {
  name: 'myCookie',
  value: 'myValue',
  domain: 'some domain',
  path: '/',
  version: '1',
  expires: '2015-05-30T12:30:00.00-05:00'
}).then((done) => {
  console.log('CookieManager.set =>', done);
});

*NB:* When no `domain` is specified, url host will be used instead.
*NB:* When no `path` is specified, an empty path `/` will be assumed.

// Set cookies from a response header
// This allows you to put the full string provided by a server's Set-Cookie
// response header directly into the cookie store.
CookieManager.setFromResponse(
  'http://example.com',
  'user_session=abcdefg; path=/; expires=Thu, 1 Jan 2030 00:00:00 -0000; secure; HttpOnly')
    .then((success) => {
      console.log('CookieManager.setFromResponse =>', success);
    });

// Get cookies for a url
CookieManager.get('http://example.com')
  .then((cookies) => {
    console.log('CookieManager.get =>', cookies);
  });

// list cookies (IOS ONLY)
CookieManager.getAll()
  .then((cookies) => {
    console.log('CookieManager.getAll =>', cookies);
  });

// clear cookies
CookieManager.clearAll()
  .then((success) => {
    console.log('CookieManager.clearAll =>', success);
  });

// clear a specific cookie by its name (IOS ONLY)
CookieManager.clearByName('http://example.com', 'cookie_name')
  .then((success) => {
    console.log('CookieManager.clearByName =>', success);
  });

// flush cookies (ANDROID ONLY)
CookieManager.flush()
  .then((success) => {
    console.log('CookieManager.flush =>', success);
  });

WebKit-Support (iOS only)

React Native comes with a WebView component, which uses UIWebView on iOS. Introduced in iOS 8 Apple implemented the WebKit-Support with all the performance boost.

Prior to WebKit-Support, cookies would have been stored in NSHTTPCookieStorage and sharedCookiesEnabled must be set on webviews to ensure access to them.

With WebKit-Support, cookies are stored in a separate webview store WKHTTPCookieStore and not necessarily shared with other http requests. Caveat is that this store is available upon mounting the component but not necessarily prior so any attempts to set a cookie too early may result in a false positive.

To use WebKit-Support, you should be able to simply make advantage of the react-native-webview as is OR alternatively use the webview component like react-native-wkwebview.

To use this CookieManager with WebKit-Support we extended the interface with the attribute useWebKit (a boolean value, default: FALSE) for the following methods:

Method WebKit-Support Method-Signature
getAll Yes CookieManager.getAll(useWebKit:boolean)
clearAll Yes CookieManager.clearAll(useWebKit:boolean)
clearByName Yes CookieManager.clearByName(url:string, name: string, useWebKit:boolean)
get Yes CookieManager.get(url:string, useWebKit:boolean)
set Yes CookieManager.set(url:string, cookie:object, useWebKit:boolean)
Usage
import CookieManager from '@react-native-cookies/cookies';

const useWebKit = true;

// list cookies (IOS ONLY)
CookieManager.getAll(useWebKit)
	.then((cookies) => {
		console.log('CookieManager.getAll from webkit-view =>', cookies);
	});

// clear cookies
CookieManager.clearAll(useWebKit)
	.then((succcess) => {
		console.log('CookieManager.clearAll from webkit-view =>', succcess);
	});

// clear cookies with name (IOS ONLY)
CookieManager.clearByName('http://example.com', 'cookie name', useWebKit)
	.then((succcess) => {
		console.log('CookieManager.clearByName from webkit-view =>', succcess);
  });

// Get cookies as a request header string
CookieManager.get('http://example.com', useWebKit)
	.then((cookies) => {
		console.log('CookieManager.get from webkit-view =>', cookies);
	});

// set a cookie
const newCookie: = {
	name: 'myCookie',
	value: 'myValue',
	domain: 'some domain',
	path: '/',
	version: '1',
	expires: '2015-05-30T12:30:00.00-05:00'
};

CookieManager.set('http://example.com', newCookie, useWebKit)
	.then((res) => {
		console.log('CookieManager.set from webkit-view =>', res);
	});
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].