Wednesday, 3 May 2017

how to use the session to save data in angular,nodejs,socket.io

I need to use the session to save data in angularjs,nodejs and socket.io. When I close the page of my siteweb, I want the session is cleared also. for example:

I have a value usename in the function express

app.get('/',function(req,res,next){
    var username=req.session.username;
});

and now I need to use this value in the function socket

socket.on("message",function(){
   var usernameSocket= username;           
})

but the value of usernameSocket is not good

and when I am in angularjs,how can I get the value of req.session.username, and save it in my sessionStorage of angular?

thanks



via aline5188

No comments:

Post a Comment