Began to study NodeJS, stumbled on the session
//vars var sessionArray; //extention var express = require('express'); var session = require('express-session'); var app = express(); app.use(session({secret:sessionKey,saveUninitialized:true,resave:true})); //app app.get('/superpage',function(request,response){ sessionArray=session; if(sessionArray.datatime){ }else{ sessionArray.datatime = Math.random(); } console.log(sessionArray.datatime); response.end(""); }); This part of the code works for me completely. I go to different browsers on one page, and press F5. A different variable appears in the console, browser1 - variable 1, browser2 - variable 2 (as it should be).
Specifically, my application uses a structure where a function is responsible for each page.
function start(response, extendData1, extendData2){ sessionArray=session; if(sessionArray.datatime){ } else{ sessionArray.datatime = Math.random(); } console.log(sessionArray.datatime); response.writeHead(200, {"Content-Type": "text/html"}); response.end(); } There was a problem, in my case all the variables in the session are the same.
The question is - can anyone diagnose what is written incorrectly?