问题
Any ideas why the session variable is not set with this code ?
public function commitTransaction($cluster,$transId)
{
try {
$response = $this->client->request('PUT', 'https://' . $cluster . '/' . $transId, [
'auth' => ['id', 'pass'],
'proxy' => '',
'verify' => false,
'json' => [
'state' => 'VALIDATING'
]
]);
$res = $response->getBody()->getContents();
session()->put('commit',$res);
//dd($res);
return $res;
}
catch (RequestException $e){
var_dump($e->getResponse()->getBody()->getContents());
}
}
The request
is initiated on my constructor.
Thanks for your help.
回答1:
Try replacing your session put line from
session()->put('commit',$res);
To
Session::put('commit', $res);
来源:https://stackoverflow.com/questions/34708756/laravel-5-session-put-not-working