Categories

jQuery.cookie()

Categories: Utilities

jQuery.cookie( key )Returns: String

Plugin: jQuery.cookie

Description: Get the value of a cookie.

  • jQuery.cookie( key )

    version added: 1.0

    key   A string naming the cookie to get.

Get a previous stored cookie by a key name.

Thanks for this great plugin to Hartl.

  • Compare some versions control numbers.

    Code:
    // set a cookie
    $.cookie( 'foo', 'bar' );
    
    // get get cookie
    $.cookie( 'foo' );
    Results:
    bar

jQuery.cookie( key, value, [ options ] )Returns: String

Plugin: jQuery.cookie

Description: Set a cookie.

  • jQuery.cookie( key, value, [ options ] )

    version added: 1.0

    key   A string naming the cookie to set.

    value   The new cookie value.

    options   A map of additional options pass to the method.

Set a new cookie.

  • Set some cookies.

    Code:
    // set a cookie
    $.cookie( 'foo', 'bar' );
    
    // set a cookie for one week
    $.cookie( 'foo', 'bar', {expires:7} );
  • expires

    version added: 1.0

    A number of days as storability or an expire date for the cookie.

  • path

    version added: 1.0

    A path prefix to limit the validity of the cookie to a specific path / path prefix.

  • domain

    version added: 1.0

    A domain name to limit the validity of the cookie to a specific domain.

  • secure

    version added: 1.0

    A boolean indication whether to access the cookie allows only from SSL (https).