All Projects → stefangabos → Zebra_Cookie

stefangabos / Zebra_Cookie

Licence: LGPL-3.0 License
A ridiculously small (~500 bytes minified) JavaScript API for writing, reading and deleting browser cookies

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Zebra Cookie

Cookie Universal
Universal cookie plugin, perfect for SSR
Stars: ✭ 376 (+2406.67%)
Mutual labels:  cookie, cookies
Meteor-Cookies
🍪 Isomorphic bulletproof cookie functions for client and server
Stars: ✭ 41 (+173.33%)
Mutual labels:  cookie, 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 (+6666.67%)
Mutual labels:  cookie, cookies
Cookies.js
Simple cookie framework with full Unicode support
Stars: ✭ 254 (+1593.33%)
Mutual labels:  cookie, cookies
contao-cookiebar
Display the information about cookies on your Contao website
Stars: ✭ 27 (+80%)
Mutual labels:  cookie, cookies
Ngx Cookie Service
Angular (4.2+ ...11) service for cookies. Originally based on the `ng2-cookies` library.
Stars: ✭ 363 (+2320%)
Mutual labels:  cookie, cookies
cookie-editor
A powerful browser extension to create, edit and delete cookies
Stars: ✭ 245 (+1533.33%)
Mutual labels:  cookie, cookies
Vue Cookies
A simple Vue.js plugin for handling browser cookies
Stars: ✭ 293 (+1853.33%)
Mutual labels:  cookie, cookies
nginx cookie flag module
Module for Nginx which allows to set the flags "HttpOnly", "secure" and "SameSite" for cookies.
Stars: ✭ 101 (+573.33%)
Mutual labels:  cookie, cookies
CockyGrabber
C# library for the collection of browser information such as cookies, logins, and more
Stars: ✭ 46 (+206.67%)
Mutual labels:  cookie, 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 (+973.33%)
Mutual labels:  cookie, cookies
cookies
Manage your cookies on client and server side (Angular Universal)
Stars: ✭ 40 (+166.67%)
Mutual labels:  cookie, cookies
Client-Storage
🗄 Bulletproof persistent Client storage, works with disabled Cookies and/or localStorage
Stars: ✭ 15 (+0%)
Mutual labels:  cookie, cookies
cookies
Convenient way to use cookies with PSR-7
Stars: ✭ 17 (+13.33%)
Mutual labels:  cookie, cookies
PolishCookieConsent
Polish Cookie Consent is an extension, which automatically accepts privacy policy/GDPR on websites.
Stars: ✭ 17 (+13.33%)
Mutual labels:  cookie, cookies
yii2-cookiemonster
Yii extension to manage cookie warning
Stars: ✭ 16 (+6.67%)
Mutual labels:  cookie
igcreator
Instagram mass account creator with proxies 🔃 and cookies 🍪 support
Stars: ✭ 35 (+133.33%)
Mutual labels:  cookies
http
Aplus Framework HTTP Library
Stars: ✭ 113 (+653.33%)
Mutual labels:  cookie
rabid
🍪 A CLI tool and library allowing to simply decode all kind of BigIP cookies.
Stars: ✭ 36 (+140%)
Mutual labels:  cookies
javascript-cookie-control
Javascript module for controling cookie consent on your website
Stars: ✭ 18 (+20%)
Mutual labels:  cookie

zebrajs

Zebra Cookie  Tweet

A ridiculously small (~500 bytes minified) JavaScript API for writing, reading and deleting browser cookies

npm Total Monthly License

Features

  • very easy to write, read and delete cookies
  • simple and intuitive syntax
  • extremely small: with around 500 bytes when minified (350 bytes gzipped), it is probably the smallest and most optimized API for handling browser cookies

🎂 Support the development of this project

Your support means a lot and it keeps me motivated to keep working on open source projects.
If you like this project please it by clicking on the star button at the top of the page.
If you are feeling generous, you can buy me a coffee by donating through PayPal, or you can become a sponsor.
Either way - Thank you! 🎉

Star it on GitHub Donate

Demo

See the demos

Installation

Zebra Cookie is available as a npm package. To install it use:

# the "--save" argument adds the plugin as a dependency in packages.json
npm install zebra_cookie --save

Zebra Cookie is also available as a Bower package. To install it use:

# the "--save" argument adds the plugin as a dependency in bower.json
bower install zebra_cookie --save

How to use

Load Zebra Cookie:

<script src="path/to/zebra_cookie.min.js"></script>

Alternatively, you can load Zebra Cookie from JSDelivr CDN like this:

<!-- for the most recent version, not recommended in production -->
<script src="https://cdn.jsdelivr.net/npm/zebra_cookie@latest/dist/zebra_cookie.min.js"></script>

<!-- for a specific version -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/zebra_cookie.min.js"></script>

<!-- replacing "min" with "src" will serve you the non-compressed version -->

Usage

// at this point "Cookie" object will be available in the global namespace
// the object exposes 3 methods that you can use to write, read and delete cookies

// create a session cookie (expires when the browser closes)
Cookie.write('cookie_name', 'cookie_value');

// create a cookie that expires in 1 day
Cookie.write('cookie_name', 'cookie_value', 24 * 60 * 60);

// read a cookie’s value
// following the examples above, this should return "cookie_value"
Cookie.read('cookie_name');

// the "read" method returns null if the cookie doesn’t exist
Cookie.read('non_existing_cookie_name');

// delete the cookie
Cookie.destroy('cookie_name');

Methods

destroy(name)

Removes a cookie from the browser.

Returns TRUE on success or FALSE otherwise.

Arguments

name - the name of the cookie to remove

// create a session cookie (expires when the browser closes)
Cookie.write('cookie_name', 'cookie_value');

// delete the cookie
Cookie.destroy('cookie_name');

read(name)

Reads the value of a cookie.

Returns the value of the requested cookie or null if the cookie doesn't exist.

Arguments

name - the name of the cookie to read

// create a session cookie (expires when the browser closes)
Cookie.write('cookie_name', 'cookie_value');

// read a cookie's value
// following the examples above, this should return "cookie_value"
Cookie.read('cookie_name');

write(name, value, [expire = 0], [path = /], [domain = ""], [secure = FALSE])

Sets a cookie in the browser.

Returns TRUE if the cookie was successfully set, or FALSE otherwise.

Arguments

name - The name of the cookie to set

value - The value to set

expire - (optional) - The life time of the cookie, in seconds. If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

path - (optional) - The path on the server in which the cookie will be available on. If set to /, the cookie will be available within the entire domain. If set to /foo/, the cookie will only be available within the /foo/ directory and all subdirectories such as /foo/bar/ of the domain. If omitted, it will be set to /.

domain - (optional) - The domain that the cookie will be available on. To make the cookie available on all sub-domains of example.com, domain should be set to to .example.com. The . (dot) is not required but makes it compatible with more browsers. Setting it to www.example.com will make the cookie available only in the www sub-domain.

secure - (optional) - Indicates whether cookie information should only be transmitted over a HTTPS connection. Default is FALSE.

// create a session cookie (expires when the browser closes)
Cookie.write('cookie_name', 'cookie_value');

// create a cookie that expires in 1 day
Cookie.write('cookie_name', 'cookie_value', 24 * 60 * 60);
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].