php - Laravel Socialite 如何在重定向到提供者后将变量保留在会话中
问题描述
欢迎
我正在开发一个多语言网站,我目前正在使用社交媒体(Socialite)登录
问题是:
在使用谷歌登录之前,我locale
在会话中保存了一个变量('en','fr'.. etc) . 但是在登录并从 Google 重定向到我的网站后,我发现我在会话中放入的变量的值是null
使用以下代码
/* this method will redirect user from my website to google for auth */
public function redirectToGoogleProvider()
{
Session::put("locale", app()->getLocale());
return Socialite::driver('google')->redirect();
}
/* this method will called when auth finished */
public function handleGoogleProviderCallback()
{
$locale = Session::get('locale');
dd($locale); // output: null
}
编辑:我在使用cookie
谢谢时遇到了同样的问题。
解决方案
推荐阅读
- javascript - 我是否正确理解了这个关于 getter 函数的规范?
- sql - 如何在 SQL 中循环 concat?
- windows - 使用 ADB 命令操作多个设备
- jena - JENA 和 OWL-API 有什么区别?
- laravel - Laravel/HTML 日期表列提供为空
- reactjs - 第 0 行:解析错误:React 应用程序中的数组长度无效
- pandas - 连接多行的字符串 - 第 2 部分
- flutter - 如何在 Flutter web 中使用 .env?
- java - 在 LWJGL 2 中隐藏创建的显示
- javascript - 为什么我在 JSON 文件中收到错误消息“SyntaxError: unexpected token: ':'”?