我在AngularJS中使用来自客户端的Web RestFUL API.
app.controller('LoginController',[ '$http','$cookies',function($http,$cookies) { this.credentials = {}; this.http = $http; this.login = function() { console.log(this.credentials); var authdata = btoa( this.credentials.username + ':' + this.credentials.password ); $http.defaults.headers.common['Authorization'] = 'Basic ' + authdata; console.log($http); var res = $http.post("http://API_NAME/library"); res.success(function(data,status,header){ alert('Successfull func'); console.log($cookies.get('JSESSIONID')); }); res.error(function(data,headers,config) { console.log('Error Log'); }); }; },]);
然后,我有这个Http标题响应
Set-Cookie:JSESSIONID=azekazEXAMPLErezrzez; Path=/; HttpOnly
我正在使用ngCookies获取JSESSIONID值,然后在我的浏览器中手动创建它,但我无法访问它.
我已经在StackOverflow中看到了关于此的所有帖子,但它们已被弃用或完全不清楚.
感谢您的关注和帮助.