Giter Club home page Giter Club logo

easy-cookie's Introduction

EasyCookie 0.2.1 README
=======================

Simple JavaScript cookie library.  EasyCookie is licensed under the
revised BSD license; please see the file COPYING for details.  The
latest version of EasyCookie can be found at

  http://pablotron.org/software/easy_cookie

Using EasyCookie
================
Get a cookie:

  val = EasyCookie.get('some_key');

Set a cookie:

  val = 'this is a test string';
  EasyCookie.get('some_key', val);

Remove a cookie:

  old_val = EasyCookie.remove('some_key');

Check to see if cookies are enabled:

  status = EasyCookie.enabled ? 'enabled' : 'not enabled';
  alert('Cookies are ' + status);

Set also has several optional parameters, which can be passed like so:

  val = 'this is a test string';
  EasyCookie.set('some_key', val, {
    // expires in 10 days
    expires: 10,

    // limit cookie to domain 'foo.example.com'
    domain: 'foo.example.com',

    // limit cookie to path '/some/path'
    path: '/some/path',

    // restrict cookie to secure pages only
    secure: true
  });

You can also get a list of existing cookies like so:

  // get an array of cookie names
  keys = EasyCookie.keys();

See test/test.js for examples of all methods.


Notes
=====
The file "easy_cookie-min.js" is functionally identical to
"easy_cookie.js" and has been shrunk to about 1900 bytes using
Douglas Crockford's excellent Javascript minifier, which can be found at
the following URL:

  http://crockford.com/javascript/jsmin.html 

Embedding EasyCookie in an existing Javascript library is easy.
EasyCookie only exposes one reference in the global namespace (the
top-level EasyCookie object), and that can be easily embedded in an
existing API by editing easy_cookie.js (or easy_cookie-min.js) and
replacing the very first EasyCookie = with something else, for example:

  // definition of ExampleProject namespace
  ExampleProject = {};

  // more stuff here ...

  // definition in easycookie.js

  ExampleProject.EasyCookie = (function() {


About the Author
================
Paul Duncan <[email protected]>
http://pablotron.org/

easy-cookie's People

Contributors

pablotron avatar

Watchers

 avatar  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.