1

我在我的 laravel 项目中实现了 rest api。我想保存从会话中的 api 响应中获得的访问令牌。当我尝试此代码时,邮递员显示此错误:未按请求设置会话存储

<?php

  namespace App;

  use Illuminate\Http\Request;

  class AuthSession{


private $oAuthHeader;

private $request;

public function __construct(Request $request)
{

    $this->oAuthHeader = [];
    $this->request = $request;
}


/**
 * @return string
 */
public function getAccessToken()
{
    if($this->request->session()->has('accessToken'))
        echo $this->request->session()->get('accessToken');
    else
        return null;
}

/**
 * @param string $accessToken
 * @return AuthSession
 */
public function setAccessToken($accessToken)
{
    $this->request->session()->put('accessToken',$accessToken);
    return $this;
}
}
4

0 回答 0