My Laravel application works fine in on my local machine and on my staging server. But when I deployed to my production server the login form is not working. Every time I try to login to the admin panel it shows my
419
Sorry, your session has expired. Please refresh and try again.
My Head Tag contains <meta name="csrf-token" content="XXX">
My login form contains <input type="hidden" name="_token" value="XXX">
What have I tried so far:
php artisan key:generate
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan cache:clear
SESSION_DRIVER
from file to databaseThe only thing that kind of worked but was unsafe and was for debugging purpose
In the VerifyCsrfToken class, I added "api/login" & "api/register" in protected $except
and the form worked. Like this
namespace FleetCart\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
"api/login",
"api/register"
];
}
Please help me understand how to resolve this.
Thanks in advance.
Finally after spending 3 days I found the solution.
@Snapey helped me fixing this issue.
You can see the answer here: https://laracasts.com/discuss/channels/laravel/419-session-expired-without-event-authentication-after-deployment-laravel-57
In my case, there was an extra space before starting <?php
tag.