angularjs - express session doesn't work -


i building simple login function express-session. however, session object doest work. logic req.session user_id when user created successfully. validation check req.session, program doesn't go way. first console in login api print userid property in req.session, req.session in validate doesn't. don't know going on ?

app.use(session({    secret : 'xxxyyy',    cookie :{      maxage : 60*1000    } }));   app.get('/api/validate',function(req,res){   console.log(req.session);   var _userid = req.session._userid;   if(_userid) {     user.findbyuserbyid(_userid,function(err,user){         if (err) {             res.json(401,{msg:err})         } else{             res.json(user);         };     })   }else{     res.json(401,null);   }; })  app.post('/api/login',function(req,res){   var email = req.body.email;   if (email) {     user.findbyemailorcreate(email,function(err,user){         if (err) {             res.json(500,{msg:err})         } else{              req.session._userid = user._id;             console.log(req.session)             res.json(user)         };     })   } else {     res.json(403);   }; }) 

my book says session cleaned when server restarted. client side angular application

    $http({         url : "/api/login",         method : 'post',         data : {             email : $scope.email         }     }).success(function(user){         console.log(user)         $scope.$emit('login',user);         $location.path('/') 

i don't think path change restart server. dose tell me why ? or how improve code.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -