当我发出某些请求时,Symfony会失去会话



我正在使用angular 2,我对symfony的请求只有这个问题,当我提出某些请求时,syfony失去了会话,但从远处到远处它是有效的,我不知道它可以是什么,我会在下面留下一个有效的请求,另一个不工作,如果你能帮助我,我会很感激

这是

getOneEntidade(entid:number)
{
  this.token = this.cookieService.get("auth");
  let headers = new Headers({  'Content-Type': 'text/html' , 'Access-Control-Allow-Credentials': 'true', 'Authorization': 'Bearer ' + this.token});
  let options = new RequestOptions({ headers: headers, body: '', withCredentials: true});    
  return this.http.get(this.urlbase + "oneentidades/" + entid , options)
  .map((response: Response) => response.json());
}

这行不通。

getpesquisa(pesquisa:string,  pag:number){
  this.token = this.cookieService.get("auth");
  let headers = new Headers({'Content-Type': 'text/html','Access-Control-Allow-Credentials': 'true', 'Authorization': 'Bearer ' + this.token});
  let options = new RequestOptions({ headers: headers, body: '', withCredentials: true});    
  return this.http.get(this.urlbase + "pesquisaentidades/" + pesquisa + "/" + pag , options)
  .map((response: Response) => response.json());
}

将此添加到config.yml:

framework:
    session:
        cookie_domain: ".YOUR_DOMAIN"
        name: SFSESSID
        cookie_httponly: false

最新更新