Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>See the plugin:</p> <p><a href="https://github.com/carhartl/jquery-cookie" rel="noreferrer">https://github.com/carhartl/jquery-cookie</a></p> <p>You can then do:</p> <pre><code>$.cookie("test", 1); </code></pre> <p>To delete:</p> <pre><code>$.removeCookie("test"); </code></pre> <p>Additionally, to set a timeout of a certain number of days (10 here) on the cookie:</p> <pre><code>$.cookie("test", 1, { expires : 10 }); </code></pre> <p>If the expires option is omitted, then the cookie becomes a session cookie and is deleted when the browser exits.</p> <p>To cover all the options:</p> <pre><code>$.cookie("test", 1, { expires : 10, // Expires in 10 days path : '/', // The value of the path attribute of the cookie // (Default: path of page that created the cookie). domain : 'jquery.com', // The value of the domain attribute of the cookie // (Default: domain of page that created the cookie). secure : true // If set to true the secure attribute of the cookie // will be set and the cookie transmission will // require a secure protocol (defaults to false). }); </code></pre> <p>To read back the value of the cookie:</p> <pre><code>var cookieValue = $.cookie("test"); </code></pre> <p>You may wish to specify the path parameter if the cookie was created on a different path to the current one:</p> <pre><code>var cookieValue = $.cookie("test", { path: '/foo' }); </code></pre> <p><strong>UPDATE (April 2015):</strong></p> <p>As stated in the comments below, the team that worked on the original plugin has removed the jQuery dependency in a new project (<a href="https://github.com/js-cookie/js-cookie" rel="noreferrer">https://github.com/js-cookie/js-cookie</a>) which has the same functionality and general syntax as the jQuery version. Apparently the original plugin isn't going anywhere though.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload