0
votes

I used a tutorial for implementing Google's 2FA: https://www.sitepoint.com/2fa-in-laravel-with-google-authenticator-get-secure/

The ValidateSecretRequest class extends from App\Http\Requests; but I don't have this class in my "Requests"-folder. So I used use Illuminate\Http\Request;

But when I call this class in the Controller I get an error.

RuntimeException - Session store not set on request …/vendor/laravel/framework/src/Illuminate/Http/Request.php 411

public function session()
    {
        if (! $this->hasSession()) {
            throw new RuntimeException('Session store not set on request.');
        }

        return $this->getSession();
    }

Does anybody know how to handle?

1
did you use the command php artisan make:request ValidateSecretRequest to generate the class? That should create a request class in your app/http/requests folderpseudoanime
Yes I used but it didn't create the request class.user6508942
It seems there's a problem with hasSession(). Why is it empty?user6508942

1 Answers

1
votes

I had the same issue before but I fixed it by setting permissions of storage/* like:

chmown -R www-data storage/*

If you're using files as session driver, it's probably because of these permissions issues.

Edit: It also works with database sessions