Tree.js doesn't seem to allow you to set attributes for a cookie. So I just had to rewrite the _saveState() method for Tree :
var treeControl = new dijit.Tree({ model: treeModel, showRoot: false, openOnClick: false, cookieName: "OrganizationUnitTreeState", _saveState: function(){
This is the last line of code that does the trick. dojo.cookie() accepts a list of key / value pairs that will be converted into cookie attributes, so if you want all other attributes to be set, you will.
source share