问题
Using Codebird, I request oauth token here
$reply = $cb->oauth_requestToken(array(
'oauth_callback' => 'http://localhost/laravel/public/callback'
));
print_r($reply);
$cb->setToken($reply->oauth_token, $reply->oauth_token_secret);
Session::put('oauth_token', $reply->oauth_token);
Session::put('oauth_token_secret', $reply->oauth_token_secret);
Session::put('oauth_verify', true);
Session::save();
$auth_url = $cb->oauth_authorize();
header('Location: ' . $auth_url);
die();
Variables are all correctly put into session here (as I can test this by putting a die() after the print)
Callback code from Twitter Authorisation
$verify = $_GET['oauth_verifier'];
Session::put('oauth_token', $_GET['oauth_token'] );
Session::put('oauth_verify', true);
Session::save();
var_dump(Session::all());
header('Location: ' . "http://localhost/laravel/public/test?oauth_verifier=".$verify);
die();
var_dump here does not show the session variables that were stored in the code segment above and after the redirect to localhost, session variables are empty.
Is there something I have missed out in Laravel (5)?
回答1:
Issue was in config/session
'driver' => env('SESSION_DRIVER', 'file')
env 'SESSION_DRIVER' was empty, changing the line to:
'driver' => 'file'
Solves the problem and now session variables persist on redirects.
来源:https://stackoverflow.com/questions/30545235/laravel-5-session-variables-not-persisting-after-redirects-twitter-oauth