Giter Club home page Giter Club logo

jquery.cookie's Introduction

jQuery.cookie

Simple jQuery plugin for handling cookies. This is not a full fledged dependency management solution.

Usage

Set Cookie

var value = 'Sample Cookie';
$.cookie('my-cookie-name', value);

By default the cookie created by $.cookie method will be a session cookie and will be automatically deleted at the end of the current browser session. If you want the cookie to persist beyond current session, you can specify a TTL in seconds using the expires option.

var value = 'Sample Cookie';
// This cookie will persist for 1 hour (3600 seconds) and will not
// be deleted if the browser session is ended before the specified TTL
$.cookie('my-cookie-name', value, {expires: 3600});

Read Cookie

var value = $.cookie('my-cookie-name');
alert('Value of "my-cookie-name" is ' + value);

Delete Cookie

A cookie can be deleted by passing null as its value. It can also be deleted by setting a negative value for expires option.

var value = $.cookie('my-cookie-name');
alert('Value of "my-cookie-name" is ' + value);

Options

Available options are

Parameter Description
expires The cookie TTL in seconds
domain The domains from which the cookie is accessible. By default the cookie is accessible only from the same domain from which it is set. If you wish to allow access to the cookie from subdomains, use '.yourdomain.com'
path By default, the cookie is available only from the path where it was set. If you wish to access the cookie from location outside the path, set the path accordingly. Setting path to / will make the cookie available from the entire site.
secure Determines whether the cookie is available from http urls.

Credits

This plugin was created for Prokerala.com.

jquery.cookie's People

Contributors

joycebabu avatar

Watchers

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