GLOBAL data per HTTP/Session request?

前端 未结 5 2229
刺人心
刺人心 2021-01-05 23:56

QUESTION:

Is there any way to create a variable storage in per session/http request? The variable must be globally accessible and different

5条回答
  •  既然无缘
    2021-01-06 00:33

    if i'm right to understood your question you can try to make global variable in node js which can stored username

    you can use global array with unique id

    suppose user1 hit the http request therefore you store like this in node js

    if(!username)
       username = [];
    
    if(!uniqId)
       uniqId = 0;
    uniqId++;
    
    username[uniqId] = 'xyz';
    

    similar like this it is working

提交回复
热议问题