Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9030355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:28:11+00:00 2026-06-16T07:28:11+00:00

app.post(‘/register’, express.BodyParser(), function (req, res){ var newu = new UserModel({}); newu.user = req.body.nuser; newu.pass

  • 0
app.post('/register', express.BodyParser(), function (req, res){

   var newu = new UserModel({});

   newu.user = req.body.nuser;
   newu.pass = req.body.npass;
   newu.mail = req.body.nmail;

   var pathu = __dirname + '/users/' + req.body.nuser;

   newu.save(function (err, newu){

       req.session.user = new.user;

       if(err) throw err;

       fs.mkdir(pathu, function (err){

           if (err) throw err;

        });    

   });

   res.redirect('/home);

});

Always when the fs.mkdir is executed, I lose all the current Express’ sessions, is there any way to execute fs.mkdir and keep all the Express’ sessions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:28:13+00:00Added an answer on June 16, 2026 at 7:28 am

    Not sure how it’s causing your symptoms, but this line:

    req.session.user = new.user;
    

    should likely be:

    req.session.user = newu.user;
    

    UPDATE

    The root of the problem is that creating the directory is triggering nodemon to restart the app and the default in-memory session store loses all sessions when that occurs. The fix is to use a persistent session store like Redis via connect-redis.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a nodejs app using bodyparser(), and this route : app.post('/users', function(req, res){
I have an express app and a POST route: app.post('/test', function(req, res){ //res.send(req.body.title +
app.post('/login', function (req, res) { var login = req.body.login; var pass = req.body.pass; var
var express = require('express'); var app = express(); app.use(express.cookieParser('keyboard 123')); app.get('/', function(req, res){ res.sendfile('./login.html');
How can I test a function like this? app.post '/incoming', (req,res) -> console.log Hello,
I have something like this in Express.js Framework app.post('/:username/:slug', user.fn); Now I want to
Having a XML response like: app.post '/incoming', (req,res) -> console.log Hello, incoming call! message
function DatabaseConnect(req, res) {...} function CreateNewUser(req, res) {...} function Go (app, req, res) {
In express, I have defined some routes app.post(/api/v1/client, Client.create); app.get(/api/v1/client, Client.get); ... I have
I'm trying to make my app post on the user's wall. Under the post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.