Code Monkey home page Code Monkey logo

dough's Introduction

Dough, A Cookie Plugin for jQuery

Dough is an easy to use cookie plugin for jQuery with powerful features. Dough can auto set your domain name with ‘.’ prefix so your cookies work with subdomains and will allow you to easily go from local to staging to product servers with out a problem.

Info

Developed by Nathan Searles, http://nathansearles.com

For updates, follow Nathan Searles on Twitter

Dough is licensed under the Apache license.

Examples and Instructions

Check out an example at http://nathansearles.com/plugin/dough/

Create cookie
$.dough("cookieName", "cookieValue");

Read cookie
$.dough("cookieName");

Delete cookie
$.dough("cookieName", "remove");

Note: If setting the path to “current”, you must also define that when removing the cookie.

$.dough("cookieName", "remove", { path: "current" });

Set full cookie
$.dough("cookieName", "cookieValue", { expires: 365, path: "current", domain: "auto", secure: true });

Example cookie has a name of “cookieName”, a value of “cookieValue”, will expire in 1 year, have path of current page, domain will be autodetected and is set to secure for a use under https://.

Definition
$.dough([name], [value], { [options] });

JSON Support

Create JSON cookie
$.dough("jsonCookie", "{'someName':'someValue','someOtherName':'someOtherValue'}");

Read JSON cookie
$.dough("jsonCookie").someName;

That will return ‘someValue’

Options Definition

  • expires: Days ’til cookie expires
  • path: Default is root ‘/’, set to ‘current’ to use the path of current page
  • domain: Auto detect and set domain with subdomain prefix
  • secure: Set to true if you’re using https://

Changelog

  • 1.3
    • Fixed: issue with JSON detection
  • 1.2
    • Fixed: issue with auto domain detection
    • Cleaned up a few things
  • 1.1
    • New: Support for JSON in cookie value
  • 1.0
    • Initial release

dough's People

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.