getting at client cookies server side

Showing 1-5 of 5 messages
getting at client cookies server side Tim Heckel 1/13/13 6:59 AM
I have a requirement where I need to check if a client cookie exists that was set at a different domain...using javascript client side with document.cookie won't work for because what I get back is restricted to my current domain. I've seen this answer on SO and am posting this question as a follow-up. (I've also made a comment on that thread).

Ideally, there'd be a simple baked-in mechanism to do this. I'm going to look into the source a bit more. For the time being, what about this module?


And this creates the object in a node context -- the question is, how do we get a handle on the req object from within Meteor's server side code?
server = http.createServer( function( req, res ) {
  var cookies = new Cookies( req, res, keys )
Re: getting at client cookies server side Tim Heckel 1/13/13 8:20 PM
So I haven't found an answer yet, but I did discover the use of the connect middleware package per this SO answer. One of the modules included in the connect middleware is a cookieParser, and from my look at the accounts-oauth-helper/oauth_server.js file, this is what I've been able to piece together thus far:

 __meteor_bootstrap__.app
    .use(connect.cookieParser())
    .use(function(req, res, next) {
console.log("here?");
      Fiber(function () {
        console.log(JSON.stringify(req.cookies));
      }).run();
    });

I have this inside a regular isServer block, but it's not emitting anything to the console yet. Any thoughts?
Re: [meteor-talk] Re: getting at client cookies server side Dror 1/13/13 8:24 PM
where are you getting the request and response objects from? If you
have the request object, getting the cookies should be easy, but I
don't know that Meteor provides that.
> --
>
>
Re: [meteor-talk] Re: getting at client cookies server side Avital Oliver 1/14/13 1:05 PM
I copied this code into a server file in an empty project and all was printed as expected (though the app didn't load since you didn't call next() at the end of the middleware).

Could it be that you placed this within a Meteor.startup() block? That would get executed after the server loads its own middleware which blocks any additional ones.

On Sun, Jan 13, 2013 at 8:20 PM, Tim Heckel <timh...@gmail.com> wrote:
__meteor_bootstrap__.app
    .use(connect.cookieParser())
    .use(function(req, res, next) {
console.log("here?");
      Fiber(function () {
        console.log(JSON.stringify(req.cookies));
      }).run();
    });


Re: [meteor-talk] Re: getting at client cookies server side Tim Heckel 1/15/13 2:47 PM
Thanks Avital. You were correct; I had my code in a startup function. Thanks very much!

In the world I come from (C# / .NET), you typically can get all the client's cookies regardless of its domain on the server. The cookieParser looks to give me all cookies bound to the current domain. I will keep digging, but what I really need to know is whether a cookie set at a different domain is present.

Does that make sense?