如何查看x-session的状态?

我使用的是angular 6,使用的是rest api,后端是laravel php。没有令牌,如果您已登录,您将获得一个x-session,您可以在邮递员标头中看到它

X-Session →1948c514b7e5669c284e85d6f612f9bd491
X-Session-Expiry →2038-08-02T09:19:03+00:00

如何从angular检查x-sessionX-Session-Expiry的值?在api endpoind中没有任何与session相关的东西。我需要知道会话是否仍然打开,当会话过期时,我需要注销用户。

当您登录时,可以从angular访问这些x-session值吗?它们是否存储在报头中?

服务

  login(username, password) {
    const data = {
      username: username,
      password: password
    };
    const headers = new HttpHeaders();
    headers.set('Content-Type', 'application/json');
    localStorage.setItem('headers', JSON.stringify(headers));
    return this.http.post(this.login_url, data, { headers: headers });
  }

并且我尝试向用户服务提供相同的会话

  getUsers() {
    const headers = JSON.parse(localStorage.getItem('headers'));
    return this.http.get(this.users_url, { headers: headers });
  }

但是它不工作,我没有任何用户,有解决方案吗?

转载请注明出处:http://www.insurance-fj.com/article/20230526/1507608.html