node.js session


I have a page - index.html and chat.html.

On page index.html - I have a form and inputs (input1 and input2) and the button.

When I press the button I want to save the entries using node.js. When I go to the page chat.html, I want to retrieve these values​​.

When i do refresh the page so I do not want to lose data.

Thank you for your help!

Problem courtesy of: Jenan


Node can "remember" the data on the server side, but you would probably want to use Express.js with its session store (backed by MongoDB or Redis) to keep that data even after the process restarts (unless there's no problem in loosing it).

Read more about Express on the official website and checkout these examples also:

Other resources:

How to store session values with Node.js and mongodb?
nodeJS - How to create and read session with express

Solution courtesy of: alessioalex


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.