Laravel 5 with Xdebug always throws "The payload is invalid."

If the answer doesn't work, try adding this into launch.json

{
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9001,
        "ignore": [
            "**/vendor/**/*.php"
        ]
    },

More info: https://stackoverflow.com/a/49795318/1998033


By default Laravel will encrypt, and subsequently also decrypt, all cookies on a request.

When using Xdebug to debug your application from a browser, a cookie called "XDEBUG_SESSION" is set. As this cookie was not set, and thus not encrypted, by the Laravel framework, an error will be thrown when the framework automatically detects and tries to decrypt the cookie.

The correct solution is to just add the "XDEBUG_SESSION" cookie to the exceptions array in the App\Http\Middleware\EncryptCookies middleware.

/**
 * The names of the cookies that should not be encrypted.
 *
 * @var array
 */
protected $except = [
    'XDEBUG_SESSION'
];

The @ceejayoz comment solved the issue. I run php artisan otimize, and the clear all my cookies on the browser, and it started to work properly.