对于后端,我使用Spring Framework和'Shiro'进行身份验证,
对于前端,我使用的是Angular 5.
如果我从postman调用我的登录API,那么在我使用logout API之前,我将获得相同的用户会话.(哪个是对的)
但是当我从我的角度5调用我的登录API时,我在每次调用时都会得到不同的用户会话.(这是错的.)
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import 'rxjs/add/operator/toPromise';
@Injectable()
export class LoginService {
private headers = new Headers({'Content-Type': 'application/x-www-form-urlencoded'});
private _url:string = "v1/login";
constructor(private http: HttpClient) { }
login(){
const data = {userName:"root", password:"root"};
return this.http.post(this._url,{headers: this.headers},{params : data})
.subscribe(data => {sessionStorage.setItem("jsessionid",JSON.parse(JSON.stringify(data)).jsessionid)});
}
}
Run Code Online (Sandbox Code Playgroud)
每次调用'jsessionid'都会改变,如''所示
angular ×1