title: Global variable across all controllers in Node JS
body: <p>I am trying to have a variable which can be accessible by all controllers in my node project. Currently in one controller I have:</p>
  
  <pre><code>        var ua = req.headers['user-agent'];
          var isMobile = "no";
          if(/mobile/i.test(ua))
              isMobile="yes";
  </code></pre>
  
  <p>It's pointless to copy past all of this for all my controllers and pass the isMobile variable to the view. I'd like to get the value of isMobile set once, and then pass it wherever I want from my controllers.</p>
  
  <p>Is there an easy way to do this rather than have those 4 lines of code copy pasted in every controller?</p>
  
  <p>Thanks</p>