Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

wassim.hattab's avatar

TokenMismatchException in VerifyCsrfToken.php line 53

Hello im getting this error while i'm sending the token in the login form via ajax

TokenMismatchException in VerifyCsrfToken.php line 53

HTML:

<input type="hidden" id="_token" name="_token" value="{{{ csrf_token() }}}" />
          <div id="logerror_msg" class="mt15 for14br" > &nbsp;</div>
          <div class="bb dib mt10 ">
            <input type="email" id="loginemail" onkeypress="checksubmit(event,login_submit)"class="transparent search-inpt text-center " placeholder="Email" name="email" value="">
          </div>
          <div class="bb dib mt10 ">
            <input type="password" id="loginpassword" onkeypress="checksubmit(event,login_submit)" class="transparent search-inpt text-center " placeholder="Password" name="password">
          </div>
          <input type="hidden" id="return_url_login" value="<?php echo Request::url();?>">
          <input type="submit" id="login_submit" class="text-center mt20 inpt-2 for14b btn-action btn btn-b" value="SIGN IN">

This is my js:

var passemail = 'email=' + logemail + "&pwd=" + logpassword + '&_token=' + _token.val();

            $.ajax({
                type: 'post',
                data: passemail,
                url: 'http://www.linteractif-ongoing.com/3alsouk/user_login_submit',

                success: function(responseText) {
                    if (responseText) {
                        if (responseText == "success") {
                            window.location = returl;
                        } else if (responseText == "notconfirm") {
                            $('#logerror_msg').html('Email not yet validated, please check your email');
                        } else if (responseText == "block") {
                            $('#logerror_msg').html('User blocked by administrator');
                        } else {
                            $('#logerror_msg').html('Invalid Login Credentials ');
                        }

                    }
                }
            });

It was working normally and suddenly it stopped working with the token error and in the networking tool i can see that the token is sent

Any solution?

0 likes
1 reply

Please or to participate in this conversation.