Cookies module: readBrowserCookies cannot be called server-side

7 views
Skip to first unread message

Andy Gold

unread,
Feb 19, 2012, 2:29:56 PM2/19/12
to kanso
Hi

I have been trying to read a local cookie from within my lists.js, but
I'm getting the error readBrowserCookies cannot be called server-side.

It says in the cookies module read.me that you can use them within
lists server side, but its not working for me.

I've added var cookie = require('cookies'); to the top of lists.js and
then I'm trying to read the cookie with var id =
cookie.readBrowserCookie('id');

Can anyone help me out?

Thanks

Andy

Ryan Ramage

unread,
Feb 19, 2012, 2:36:41 PM2/19/12
to ka...@googlegroups.com
Does not seem it can be called serverside:

https://github.com/kanso/cookies/blob/master/cookies.js#L24

Reading through the modules there does not seem to be a serverside
version. You might want to explore the req.headers.cookie (not sure
this is exact). You can fork and add to the module if you want ;)

Ryan

Andy Gold

unread,
Feb 19, 2012, 2:43:12 PM2/19/12
to kanso
Hi Ryan

Thanks, thats where the error is coming from, but I was going by this
line in the read.me "Utility functions for reading and setting cookies
in the browser and from server-side CouchDB functions (lists, shows,
updates etc)." Doesn't this mean it should be able to from a server
side lists function?

Andy

Ryan Ramage

unread,
Feb 19, 2012, 2:51:29 PM2/19/12
to ka...@googlegroups.com
Andy,

Yes, it looks like the readme does not match the code. Unfortunately
the code wins.
I have opened a github issue here:

https://github.com/kanso/cookies/issues/2

Also this should include updating the readme.

Andy Gold

unread,
Feb 19, 2012, 2:56:43 PM2/19/12
to kanso
Hi Ryan

Thanks.

Caolan McMahon

unread,
Feb 19, 2012, 9:22:09 PM2/19/12
to ka...@googlegroups.com
Looks like there's a function to add cookie headers to a response from
a list function but not to parse incoming cookies sent with a request.

I guess it never came up... until now ;)

Pull requests welcome,

Caolan

Reply all
Reply to author
Forward
0 new messages