aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2013-06-14 11:28:54 -0400
committerSteve Clay <steve@mrclay.org>2013-06-14 11:28:54 -0400
commitafb0cef118a59c86e649e0717748c299a05f2427 (patch)
tree6d650a544272f5c6b0228cca7dad1f599b3c3d7a /js/lib
parentd2b525a8c9d4926944ad4a9126dbd266dc823a9b (diff)
downloadelgg-afb0cef118a59c86e649e0717748c299a05f2427.tar.gz
elgg-afb0cef118a59c86e649e0717748c299a05f2427.tar.bz2
elgg.session.cookie() again handles missing options.expires
Diffstat (limited to 'js/lib')
-rw-r--r--js/lib/session.js23
1 files changed, 12 insertions, 11 deletions
diff --git a/js/lib/session.js b/js/lib/session.js
index 0fc7f5c87..a8d52733c 100644
--- a/js/lib/session.js
+++ b/js/lib/session.js
@@ -14,9 +14,9 @@ elgg.provide('elgg.session');
* {string} options[domain]
* {boolean} options[secure]
*
- * @return {string} The value of the cookie, if only name is specified
+ * @return {string|undefined} The value of the cookie, if only name is specified. Undefined if no value set
*/
-elgg.session.cookie = function (name, value, options) {
+elgg.session.cookie = function(name, value, options) {
var cookies = [], cookie = [], i = 0, date, valid = true;
//elgg.session.cookie()
@@ -48,17 +48,18 @@ elgg.session.cookie = function (name, value, options) {
cookies.push(name + '=' + value);
- if (elgg.isNumber(options.expires)) {
- date = new Date();
- date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
- } else if (options.expires.toUTCString) {
- date = options.expires;
- }
+ if (options.expires) {
+ if (elgg.isNumber(options.expires)) {
+ date = new Date();
+ date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
+ } else if (options.expires.toUTCString) {
+ date = options.expires;
+ }
- if (date) {
- cookies.push('expires=' + date.toUTCString());
+ if (date) {
+ cookies.push('expires=' + date.toUTCString());
+ }
}
-
// CAUTION: Needed to parenthesize options.path and options.domain
// in the following expressions, otherwise they evaluate to undefined