Opened 9 years ago
Closed 5 years ago
#14493 closed defect (patchwelcome)
"expires" key in cookieProps object gets overwritten by dojo.cookie()
Reported by: | jpisello | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | 1.13 |
Component: | Core | Version: | 1.6.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
The dojo.cookie documentation states that the cookieProps
object can contain the "expire" key, but dojo.cookie also accepts the "expires" key. If I provide a number of days value for "exipres" in a named object that I pass to dojo.cookie, dojo.cookie overwrites the "expires" value with a string representation of a Date object representing the specified number of days hence.
E.g.
cookieOpts = { expires: 180 }; console && console.log("Before dojo.cookie(): expires = " + cookieOpts.expires + " (" + typeof cookieOpts.expires + ")"); dojo.cookie('myCookie', 'xyzzy', cookieOpts); console && console.log("After dojo.cookie(): expires = " + cookieOpts.expires + " (" + typeof cookieOpts.expires + ")"); cookieOpts = { expire: 180 }; console && console.log("Before dojo.cookie(): expire = " + cookieOpts.expire + " (" + typeof cookieOpts.expire + ")"); dojo.cookie('myCookie', 'xyzzy', cookieOpts); console && console.log("After dojo.cookie(): expire = " + cookieOpts.expire + " (" + typeof cookieOpts.expire + ")");
Console output:
Before dojo.cookie(): expires = 180 (number) After dojo.cookie(): expires = Wed, 13 Jun 2012 19:55:12 GMT (string) Before dojo.cookie(): expire = 180 (number) After dojo.cookie(): expire = 180 (number)
The documentation should be updated to reflect this behavior, or the overwriting behavior should be removed.
Change History (3)
comment:1 Changed 9 years ago by
comment:2 Changed 9 years ago by
Component: | General → Core |
---|
comment:3 Changed 5 years ago by
Milestone: | tbd → 1.12 |
---|---|
Resolution: | → patchwelcome |
Status: | new → closed |
Documentation was updated at some point. Would consider a pull request to support expire if that's still of interest/use.
OK, turns out the "expire" key doesn't work at all (even though that's what's documented at http://dojotoolkit.org/reference-guide/dojo/cookie.html. So the documentation definitely needs to be updated to indicate that "expires" (with the trailing "s") is the correct key, and that
dojo.cookie()
will overwrite a "number-of-days" value with a string containing the calculated expiration date, if passed a named object.Tested on Firefox 3.6.24, WinXP Professional v2002, SP3.