Opened 15 years ago
Closed 14 years ago
#536 closed enhancement (wontfix)
Make dojo.io.cookie.[set|get]ObjectCookie() work with nested objects
Reported by: | Owned by: | sjmiles | |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | IO | Version: | 0.2 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
I wanted to store nested objects into a cookie, i.e.
dojo.io.cookie.setObjectCookie("my_cookie", {window: {name: "debug", opened: true}}, 30);
Until now it only worked with one level of nesting, here is the update ...
Attachments (1)
Change History (7)
Changed 15 years ago by
Attachment: | io.cookie.diff added |
---|
comment:1 Changed 15 years ago by
Milestone: | → 0.3release |
---|---|
Owner: | changed from anonymous to sjmiles |
If the idea is to serialize some object to place in cookie, shouldn't we use an existing serializer (e.g. JSON) rather than write a new one?
comment:2 Changed 15 years ago by
Using an existing parser might be a good idea. eval is just for security issues not really feasible, but a json parser written in js might help here, but then you also want to set certain limitations on the parser, ie. that it only parses simple types, such as string, number, boolean etc. otherwise you would have the same security problems as with eval. What i wrote up was just a simple serialization into a proprietary format. {x: {y: "z"}} is converted to x.y=z ... What way should be gone: JSON parser with configurable limitations or the proprietary format?
comment:3 Changed 15 years ago by
I'm not sure what we gain from proprietary format since JSON is simple and well-defined. There are existing implementations of 'safe' JSON decoders (Crockford has one).
Whether we write a custom safe-json decoder, use an existing implementation, or write some other transcode, it should be separate from the cookie code itself. In other words, the cookie code should invoke a serializer interface (decouple the implementation).
Thanks, hope this is clear.
comment:4 Changed 15 years ago by
Milestone: | 0.3release → 0.4 |
---|
comment:5 Changed 15 years ago by
Component: | Core → IO |
---|---|
Milestone: | 0.4 → 0.5 |
any resolution on this one? moving to 0.5
comment:6 Changed 14 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Think its best not to build in serialization into cookie API. Client code can choose it's own serialization.
io.cookie.diff