title: Nodejs Express render layout : false , but it still holds
body: <p>I'm new to nodejs. I'm using express and ejs. A few hours ago, I saw that installing express-ejs-layouts could use layout in my project, which worked, but now that I was trying to improve my code, it suddenly stopped its good functioning.</p>
  
  <p>when I saw that it was not working well, I decided to go back to the working stage, it was not much code.</p>
  
  <p>app.js</p>
  
  <pre><code>var express = require('express');
  var expressLayouts = require('express-ejs-layouts');
  var path = require('path');
  var favicon = require('serve-favicon');
  var logger = require('morgan');
  var cookieParser = require('cookie-parser');
  var bodyParser = require('body-parser');
  var cors = require('cors'); 
  
  var routes = require('./routes/index');
  
  var app = express();
  
  // 
  app.set('views', path.join(__dirname, '/views'));
  app.set('view engine', 'ejs');
  //
  
  app.use(logger('dev'));
  app.use(cors()); 
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true })); 
  app.use(cookieParser());
  
  app.use(express.static(path.join(__dirname, '/public')));
  app.use(expressLayouts);
  app.use('/', routes);
  </code></pre>
  
  <p>index.js: </p>
  
  <p>//Get Home</p>
  
  <pre><code>  router.get('/', function(req, res, next) {
        res.render('index', { user : req.cookies.UserData, token_id : req.cookies.token_id});
      console.log(cookies);
      });
  </code></pre>
  
  <p>//POST login, here I check user and create a token and userdata for test</p>
  
  <pre><code>router.post('/user/login',function(req,res,next){
    ////---here all code, it's a lot----///
  
      res.cookie('token_id', token);
      res.cookie('UserData', locals );
      res.redirect('/')
  });
  </code></pre>
  
  <p>//GET login layout false</p>
  
  <pre><code>router.get('/user/login', function(req, res, next) {
        res.clearCookie('token_id');
        res.clearCookie('UserData');
        res.render('login',{layout : false});
      });
  </code></pre>
  
  <p>When going to localhost: 3000/user/login, I got an error "layout not defined". But, I used the layout variables which worked for me without problems beforehand.</p>
  
  <p>when removing the &lt;% variable%> from layout, the "/user/login" works without problems and does not use the layout.</p>
  
  <p>_Head.ejs sample variable</p>
  
  <pre><code>&lt;title&gt;&lt;%= user.title %&gt;&lt;/title&gt;
  </code></pre>
  
  <p>then create the cookies to see how it worked, and it turns out that with the cookies running and the layout variables set again, he continues telling me that "the user variable is not defined", and this code was not the one that I modified, what I was improving was a Toaster, which was the one that I eliminated</p>
  
  <p>I use nodemon always.</p>