Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Laravel 5.2 - Session #64

Closed
bugwelle opened this issue Jan 6, 2016 · 6 comments
Closed

Issues with Laravel 5.2 - Session #64

bugwelle opened this issue Jan 6, 2016 · 6 comments

Comments

@bugwelle
Copy link

bugwelle commented Jan 6, 2016

Laravel 5.2 removes important global middleware and introduces middleware groups.

This is great but also brought a "bug" to my app. All captchas were invalid since \Illuminate\Session\Middleware\StartSession::class wasn't used for the captcha image url.

Workarounds:

Add \Illuminate\Session\Middleware\StartSession::class to $middleware in Kernel.php

or

Change line 26 in CaptchaServiceProvider to:

$this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web');

My question:

Is there any other way to fix this "issue" (if it is one).

Regards,
Andre

@mewebstudio
Copy link
Owner

Hi,
The first method is most appropriate. I'm using in this way.
Thanks.

@bugwelle
Copy link
Author

Thank you :)
Could you add a note to README.md, please?

Regards,
Andre

@ayaka209
Copy link

+1 very useful, thank you!

@mewebstudio
Copy link
Owner

README.md add to note.
3e7f068

@mousavian
Copy link

Since Laravel encourage developers to write their routes in the web middleware (The Default Routes File), set another StartSession in default middleware will clear all session values that has been set by other classes.

In the same situation, second approach solved my problem.

PS: I have removed \Illuminate\Session\Middleware\StartSession::class from web middleware and added it to the default middleware array, it works fine but still I believe second approach is better.

@minibugdev
Copy link

Please note to README.md that if using web middleware on route.php must NOT ADD \Illuminate\Session\Middleware\StartSession::class to protected $middleware
(for Laravel 5.2+)

Thank you,
Teeranai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants