Laravel:在多个域上共享会话数据 [英] Laravel: share session data over multiple domains

查看:89
本文介绍了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?

提前谢谢!

推荐答案

  1. 在域A中捕获会话ID Session::getId()
  2. 通过HTTP POST将捕获的会话ID发送到域B
  3. 访问域B $sessionid_from_domainA = $_POST['session_from_A']中的已发送会话ID.
  4. 在域B Session::setId($sessionid_from_domainA)
  5. 中设置会话
  6. 在域B Session::start()
  7. 中启动会话
  1. Capture the session id Session::getId() in Domain A
  2. send the captured session id via HTTP POST to Domain B
  3. Access the sent session id in domain B $sessionid_from_domainA = $_POST['session_from_A']
  4. Set session in domain B Session::setId($sessionid_from_domainA)
  5. Start Session in domain B Session::start()

这篇关于Laravel:在多个域上共享会话数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆