2015-01-09 3 views
3

사용자가 AngularJS입니다. 만료가 세션으로 설정되어 있기 때문에 서버에서 보낸 기본 쿠키를 저장하지 못하게하고 싶습니다. 또는이 쿠키를 가져 와서 인증 값을 얻고 요청을 인증하는 데 사용할 내 쿠키에 저장하십시오. 하지만 AngularJS 또는 JavaScript를 사용하여이 쿠키를 가져올 수 없습니다. 나는 "__ngdebug"또는 "5984_recent"만 볼 수 있습니다. "AuthSession"쿠키가 HTTP로 확인되었습니다. 브라우저에서 HTTP 쿠키 가져 오기

나는 $ HTTP에서 시계 헤더를 tryied하지만라는 이름은 "-쿠키 설정", 예를 들어 서버가 반환해야 없습니다 : 그런

HTTP/1.1 200 OK 
Cache-Control: must-revalidate 
Content-Length: 43 
Content-Type: application/json 
Date: Mon, 03 Dec 2012 01:23:14 GMT 
Server: CouchDB (Erlang/OTP) 
Set-Cookie: AuthSession=cm9vdDo1MEJCRkYwMjq0LO0ylOIwShrgt8y-UkhI-c6BGw; Version=1; Path=/; HttpOnly 

내 컨트롤러의 모양을

ctr.controller("loginController", ["$scope", "$cookieStore", "$http", 
    function($scope, $cookieStore, $http) { 

    $scope.userCedential = {}; 

    $scope.login = function() { 

     var headers = {}; 
     headers["Content-Type"] = "application/json"; 

     var res = $http.post("/_session", $scope.userCedential, headers); 

     res.success(function(data, status, headers, config) { 
       var s = headers("Set-Cookie"); 

      }); 

     res.error(function(data, status, headers, config) { 

      }); 
    }; 

    }]); 

답변