title: How to define global variables in node.js
body: <p>I have a module called routeEnforcer.js which contains multiple functions and an object variable called globalUser.</p>
  
  <p>This is the routeEnforcer.js module</p>
  
  <p>I have another module called routeHandler.js which handles all the routes the application takes. I set the routeEnforcer.globalUser to the retrieved user object from the database. When I display the value using console.log, the object is set correctly.  When I display the same object in another function, the object is "undefined". I've spent hours trying to figure this out.  Can anyone help?</p>
  
  <p>This is the routeHandler.js module showing the required variables.</p>
  
  <p>This is routeHandler.js module showing the post method for login where the routeEnforcer.globalUser is set and displayed successfully.</p>
  
  <p>This is routeHandler.js module showing the get method for the properties view where the routeEnforcer.globalUser variable displays as "undefined".</p>