title: How to pass session variable from express/node to angular?
body: <p>So basically I am using angular routes and just using express to render the index page.</p>
  
  <p>I want to pass a session variable from express to angular but I dont know how to get that variable in each route of angular.</p>
  
  <p>app.js(express):</p>
  
  <pre><code>app.get('*', function (req, res) {
      res.sendFile(__dirname+'/client/views/index.html',{
          isAuthenticated:req.isAuthenticated(),
          user:req.user
      });
  });
  </code></pre>
  
  <p>Index.html</p>
  
  <pre><code>&lt;body&gt;
  &lt;div class="main" ng-view&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  </code></pre>
  
  <p>Angular application file:</p>
  
  <pre><code>var myapp=angular.module('myApp', ['ngRoute','ngStorage']);
  myapp.controller('contrl1', ['$scope' ,'$localStorage','$http', 
    function ($scope,  $localStorage,$http) {
  
    }]);
  myapp.controller('contrl2', ['$scope' ,'$localStorage','$http', 
        function ($scope,  $localStorage,$http) {
  
        }]);
  myapp.config(function($routeProvider, $locationProvider) {
    $routeProvider
     .when('/try', {
      templateUrl: '../views/view1.html',
      controller: 'contrl1',
    })
    .when('/hello', {
      templateUrl: '../views/view2.html',
      controller: 'contrl2',
  
    // configure html5 to get links working on jsfiddle
    $locationProvider.html5Mode(true);
  });
  </code></pre>
  
  <p>So basically I want to send Isauthenticated variable and user variable which will be having session values, from express to angular.How should I proceed with that such that these values are accessible to all the routes in angular and also how to get those values in respective angular controller.</p>