A
A
AleDv2016-12-06 11:58:02
Laravel
AleDv, 2016-12-06 11:58:02

Why might a TokenMismatchException be thrown other than no token?

During development, something was updated somewhere or something stopped, as a result of which the authorization form stopped working completely.
When I try to authorize, I get a TokenMismatchException, while the token is passed in the form.

<h2 class="text-center">Авторизация</h2>
        <form method="POST" action="/login" accept-charset="UTF-8" role="form" class="form-horizontal">
<input name="_token" type="hidden" value="cwgcB2m9V9IKX9ZM3VMkNiWQVmPypB2evvOAIEwh">
            <div class="form-group">
                <label for="email" class="col-sm-2 control-label">Ваш E-Mail</label>
                <div class="col-sm-8">
                    <input class="form-control" name="email" type="email" id="email">
                </div>
            </div>
            <div class="form-group">
                <label for="password" class="col-sm-2 control-label">Пароль</label>
                <div class="col-sm-8">
                    <input class="form-control" name="password" type="password" value="" id="password">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-8">
                    <label for="remember">Запомнить меня</label>
                    <input checked="checked" name="remember" type="checkbox">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2">&nbsp;</div>
                <div class="col-sm-8">
                    <button type="submit" class="btn btn-block btn-primary">Вход</button>
                </div>
            </div>
        </form>

The token is also registered in the head. I'm kind of at a loss as to what could have had such an impact and where to look now.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Sashnin, 2016-12-06
@antonsash

The value of the token does not match.
Use {{ csrf_field() }}
2nd option laravel.io/forum/01-30-2015-laravel5-tokenmismatch...
See your .env where sessions are stored.

A
Alexander, 2016-12-06
@xpert13

The token has a lifespan and may become obsolete. Those. if you load the page, and then only after 2 hours submit the form, then the transmitted token will already be invalid.
Solution: https://github.com/GeneaLabs/laravel-caffeine

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question