Search code examples
laravelmicroserviceslumen

Enabling session in lumen framework


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.

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

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.

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


Solution

  • The accepted answer is outdated.

    I answered and explained a bit how to properly do it in my answer on this question

    I also posted what is the problem on my question at Laracasts

    To quote:

    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.

    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.