Laravel session() issue

Problem: After storing a session using session() helper, other pages cannot retrieve data from session. The solution is remove “exit();” in the same function because session is saved very late.

  1. Don’t need to add session_start() manually.
  2. Don’t stop the process using “exit()” or “die()” after storing a session because session could be not saved yet.
  3. session won’t work in construct because middleware is not ready yet.
    https://stackoverflow.com/questions/39186222/laravel-5-3-auth-check-in-constructor-returning-false/39188299#39188299

Child class:

Parent Class:

Reference: