Skip to content
Browse files

A really lazy way to parse the cookie.

  • Loading branch information...
1 parent daec294 commit 0fb5732f161afae01ce8aee4be8685f130fcc3f2 @monsur committed Sep 29, 2011
Showing with 11 additions and 1 deletion.
  1. +11 −1 lib/datastore/cookie-store.js
View
12 lib/datastore/cookie-store.js
@@ -42,7 +42,17 @@ exports.CookieStore.prototype.removeAll = function() {
exports.CookieStore.prototype.load = function(req, callback) {
callback = callback || function() {};
- var cookieVal = req.cookies[this.key_];
+ var cookieVal = '{}';
+ var cookieStr = req.header('cookie', this.key_ + '=%7B%7D');
+ var start = cookieStr.indexOf(this.key_ + '=');
+ if (start != -1) {
+ start = start + this.key_.length + 1;
+ var end = cookieStr.indexOf(';', start);
+ if (end == -1) {
+ end = cookieStr.length;
+ }
+ cookieVal = unescape(cookieStr.substring(start, end));
+ }
this.store_ = MemoryStore.parse(cookieVal);
callback.call({});
};

0 comments on commit 0fb5732

Please sign in to comment.
Something went wrong with that request. Please try again.