在流明框架中启用会话 [英] Enabling session in lumen framework

查看:70
本文介绍了在流明框架中启用会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个(但让我们想象更多)微服务(API),它们需要知道经过身份验证的用户.理想情况下,我想简单地恢复他们的会话.

I have two (but let's image more) micro-services (API) which need to be aware of authenticated user. Ideally I would simple like to resume their sessions.

所有微服务都在会话中使用相同的存储:redis.

All micro-services are using same storage for sessions: redis.

所有API调用都将具有Cookie标头,因此所有服务都将能够基于该Cookie恢复会话.我已经通过PHP $ _SESSIONs成功实现了这一点.

All API calls will have Cookie header, so all services will be able to resume sessions based on that cookie. I have successfully implemented this via PHP $_SESSIONs.

现在的问题是:如何使用Laravel/Lumen来实现这一目标?

Now the question: how would you go about implementing this with Laravel/Lumen?

推荐答案

已接受的答案已过时.

在这个问题

我还在 aracasts

引用:

在您提供的链接中找到的解决方案是,它首先告诉您手动注册SessionManager以防止unresolvable depedency parameter #0 $app,然后还注册现有的SessionServiceProvider,该现有产品还绑定了另一个实例SessionManager.

the solution that is found in the link you gave is that, first it tells you to manually register the SessionManager to prevent the unresolvable depedency parameter #0 $app then also register the existing SessionServiceProvider which also binds another instance SessionManager.

存在的问题是,某些组件使用了另一个实例,而其他部分使用了新的实例,这导致我的auth attempt会话实际上被保存在put中而无法保存.

Problem with that is, some components use the other instance and other parts use the new one which causes my auth attempt session not being save despite actually being put inside.

这篇关于在流明框架中启用会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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