Giter VIP home page Giter VIP logo

zebra_cookie's Introduction

Zebra_Cookie

####An extremely small (~500 bytes minified) jQuery plugin for writing, reading and deleting cookies.

##Features

  • easily write, read and delete cookies
  • very simple and intuitive syntax, blending perfectly with jQuery
  • extremely small: with around 500 bytes when minified is probably the smallest and most optimized jQuery plugin for handling cookies

##Requirements

Zebra_Cookie requires jQuery 1.0+

##How to use First, load the latest version of jQuery from a CDN and provide a fallback to a local source, like:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="public/javascript/jquery-1.9.1.js"><\/script>')</script>

Load the Zebra_Cookie plugin

<script type="text/javascript" src="path/to/zebra_cookie.js"></script>

Usage

// inside the DOM-ready function
// a "cookie" object will be available in jQuery’s namespace
// the object exposes 3 methods that you can use to write, read and delete cookies
$(document).ready(function() {

    // 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');

});

Detailed description of available methods can be found on the project's homepage

zebra_cookie's People

Contributors

stefangabos avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.