date in session mongo node.js express

I have a problem with my dates im my sessions:

I have a user collection:

{ 
    "username" : "ant",
    "mail" : "aa@aa.aa",
    "password" : "7e240de74fb1ed08fa08d38063f6a6a91462a815",
    "date_register" : ISODate("2012-11-18T11:58:45.034Z"),
    "date_login" : ISODate("2012-11-18T11:58:45.034Z"),
    "_id" : ObjectId("50a8cd75494g6db815000001"), "__v" : 0 }

I set my user in session, the first time I fech my page with a date I have:

Sun Nov 18 2012 12:58:45 GMT+0100 (CET)

and, when I want to fetch my page an other time I have

2012-11-18T11:58:45.034Z (What I have in my db)

I create my session like that:

global.user.createSession = function(id, req, callback){
    models.user.findOne({
        _id: id
    },function(err, result){
        req.session.user = result
        callback();
    })
}

Thanks

I used to store entire user object in session until I started seeing problems like these arise. The object saved to the session is not a mongoose object.

I suggest you only store userid in the session and fetch user when you need it:

req.session.userid = user._id;


User.findById(req.session.userid, fn);