• home |
  • next
  • previous |
  • Dojo Toolkit v1.3.0 documentation »
  • Dojo »

Table Of Contents

  • dojo.cookie
    • Examples

Previous topic

dojo.contentBox

Next topic

dojo.coords

This Page

  • Show Source

dojo.cookie¶

Status:Draft
Version:0.9

Contents

  • dojo.cookie
    • Examples

dojo.cookie is your one stop for handling client side cookies. Its usage is very simple and the following example should make it clear

Examples¶

Set a cookie by clicking on the button, reload the page and click the “Get Cookie” button to check whether the cookie got set.

Note: cookies must be enabled for this to work ;)

<script type="text/javascript">
dojo.require("dijit.form.Button"); // this is there only to make things look fancy
dojo.require("dojo.cookie");

setCookie = function(){
  dojo.cookie("favouriteDish", "Nudels", {expires: 5});
};

getCookie = function(){
  alert("The value of the cookie is: "+dojo.cookie("favouriteDish"));
};
</script>
<button dojoType="dijit.form.Button" onClick="setCookie();">Set Cookie</button> <button dojoType="dijit.form.Button" onClick="getCookie();">Get Cookie</button>
© Copyright 2009, Dojo Foundation. Created using Sphinx 0.6.1.