【问题标题】:Laravel's session variables going awayLaravel 的会话变量消失
【发布时间】:2014-02-15 07:17:42
【问题描述】:

我在我的 laravel 应用中实现了一个 OAuth 1.0a 客户端。我想在用户的 Session 中存储临时凭据和访问令牌。

作为一名 POC,我使用 PHP 本机会话构建了我的代码,并使用了 $_SESSION 变量。像魅力一样工作。但是后来,我想移动我的代码并改用 laravel 的 Session 类。这就是我如何意识到 laravel 并没有保存我的会话数据。

这是相关代码的主要部分:

if (Input::get('release_name')) // ask for auth
    {
        $temporary_credentials = $server->getTemporaryCredentials();

        Session::put("temporary_credentials", serialize($temporary_credentials));
        $this->customLog(Session::get("temporary_credentials")); // this prints the string representation of my credentials

        return $server->authorize($temporary_credentials);
    }

    else if (Input::get('oauth_token') && Input::get('oauth_verifier')) // got back from provider
    {
        $this->customLog(Session::get("temporary_credentials"));
                    // here the Session::get returns null
    }

知道为什么我的temporary_credentials 在第二步“无效”了吗?

快速编辑:我正在使用“文件”驱动程序

谢谢!

【问题讨论】:

  • /app/storage/sessions 是否具有读取/写入/执行文件的正确权限?

标签: php session laravel laravel-4 session-variables


【解决方案1】:

因此,如果有人尝试在 laravel 应用程序中实现 League Oauth V1 客户端,您需要做的就是保持 Session 正常工作

header('Location: '.$url);

到这里

return \Illuminate\Support\Facades\Redirect::to($url);

【讨论】:

  • 应该在哪里进行此更改?
猜你喜欢
  • 2015-02-23
  • 2012-09-02
  • 1970-01-01
  • 1970-01-01
  • 2012-12-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多