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

johnpapi's avatar

Error 419 Sorry your session has expired when change hosting

I change my hosting and when try to login in admin or any action that include CSRF token verification appear this error.

I tried to clear website cache but nothing happened. I checked my files permissions and are correct. I remove all files in storage/framework/sessions but same issue.....

I checked also if there is any space before <?php in all files ( somewhere I readed ) but there is no space.

I already generated a new app key by terminal command , I also run

php artisan config:cache and php artisan route:clear

but nothing, the issue still there..... Any solution?

0 likes
11 replies
krisi_gjika's avatar

can you verify that sessions are being stored in the first place?

johnpapi's avatar

@krisi_gjika session save it here:

'driver' => env('SESSION_DRIVER', 'file'),

But in my hosting my project is not in public_html but in public_html/newdomain.com/

is this path affect to sessions?

johnpapi's avatar

@krisi_gjika

<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;



class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'user/deposit',
        'ipn*'
    ];
}

but my login page is newdomain.com/admin

also in session.php file

'store' => env('SESSION_STORE', null),

AhmedRagab's avatar

i think , it's probably a middleware problem in your code . keep debugging and tracing the request and all the middlewares you or laravel apply to the request.

johnpapi's avatar

@AhmedRagab I dont think, as middleware working properly in previous hosting, I dont change anything in the code.

Please or to participate in this conversation.