S
S
superkolya2018-08-28 10:52:10
Laravel
superkolya, 2018-08-28 10:52:10

What could be the problem with laravel session?

We have Laravel 5.6. I put a voyager admin panel for it. On a local wheelbarrow, everything works well, but for some reason I get a TokenMismatchException when transferring to a test site. If you comment out the VerifyCsrfToken Middleware, then when you log in, it still does not enter the admin panel. At the same time, in the storage/framework/sessions folder on the test site, each time the login page is updated, a file is created, when there is always one file on the local area. The session driver is file. The rights to the storage/framework/sessions package are 775. It seems that the test site does not hold a session and creates a new one each time, but native sessions through $_SESSION seem to work. Tried Chrome and Firefox, the problem is both there and there. Tell me what could be the problem

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
superkolya, 2018-09-01
@superkolya

I didn’t fully understand what exactly the problem was, but it turns out that the problem is in encryption. Laravel encrypts cookies by default, but in my case, for some reason, every time it could not decrypt the cookie, so it started a new session. Commented out the middleware that encrypts cookies and everything worked

K
Kairat Ubukulov, 2018-08-29
@ubukulov

Try to put the following in all forms. This code creates a token.
{{ csrf_field() }}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question