Thursday, 16 March 2017

User specific global variable in Node.js

my program looks as follows:

var globVar=[];

function1(usr){
   //calculations with globVar
}

function2(usr){
   //calculations with globVar
}

app.post('/', function(req, res) {
    var formString = req.body.filter1;
    globVar.push(formString);
    usr= req.connection.user;
    function1(usr);
    function2(usr);
    res.redirect('/');
});

req.connection.user comes from nodeSSPI module. I need to make this globVar user specific so it doesn't mixed up when users runs this app concurrently. Now it works well but only for single user :)

Thank you for your consideration on this matter.



via plska

No comments:

Post a Comment