Laravel:在多个域上共享会话数据 [英] Laravel: share session data over multiple domains
本文介绍了Laravel:在多个域上共享会话数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Laravel中构建一个多域/多商店电子商务应用程序,希望当用户在商店之间切换时保持登录状态.
I'm building a multi-domain/multi-store ecommerce application in Laravel and would like to keep the user logged in when he or she changes from store to store.
但是据我所知,Laravel的Auth服务将已登录的用户保存在会话中,并且其他域无法访问这些会话.
But for as far as I know Laravel's Auth service saves the logged in user in the session and the sessions can't be accessed by other domains.
有没有一种方法(也许是一个软件包)来实现这一目标,而又不会使我的应用程序容易出现安全问题?
Is there a way (maybe a package) to achieve this, without leaving my application prone to possible security problems?
提前谢谢!
推荐答案
- 在域A中捕获会话ID
Session::getId()
- 通过HTTP POST将捕获的会话ID发送到域B
- 访问域B
$sessionid_from_domainA = $_POST['session_from_A']
中的已发送会话ID. - 在域B
Session::setId($sessionid_from_domainA)
中设置会话
- 在域B
Session::start()
中启动会话
- Capture the session id
Session::getId()
in Domain A - send the captured session id via HTTP POST to Domain B
- Access the sent session id in domain B
$sessionid_from_domainA = $_POST['session_from_A']
- Set session in domain B
Session::setId($sessionid_from_domainA)
- Start Session in domain B
Session::start()
这篇关于Laravel:在多个域上共享会话数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文