title: AngularJS - Service return value
body: <p>I've an app using JSON user API wordpress plugin.
  I've this service to validate user cookie. First i call an API for cookie name then i try to validate cookie.</p>
  
  <pre><code>angular.module('app').service('AuthService', AuthService);
  
  AuthService.$inject = ['$http'];
  function AuthService($http) {
  return {
      isAuthenticated: isAuthenticated
  };
  function isAuthenticated(){
      return $http.get('http://somesite/pCookie.php')
        .then(function (response) {
          var authCookieName = response.data.response;
          var authCookie = getCookie(authCookieName);
          var validity;            
          $http.get('http://somesite/api/user/validate_auth_cookie/?cookie='+authCookie)
              .then(function (response) {
                  validity = response.data; 
  
              });
  
          return validity;
      });
  }
  }
  </code></pre>
  
  <p>The problems are:
  is there any other method that provide LOGGED_IN_COOKIE cookie name?
  validity is undefined because of nested functions. How can i resolve it?</p>