0

I use auth()->attempt() with remember me parameters.

if (auth()->attempt($credentials, $rememberMe)) {

When remember me is false, I can login normally,
but when remember me is true, I got an error.

RuntimeException
Cookie jar has not been set. 

I tried to set .env from SESSION_DRIVER=file to SESSION_DRIVER=cookie

but still didn't work.

I'm using Laravel 7.24 and PHP 7.4.11

Anurat Chapanond
  • 2,837
  • 3
  • 18
  • 31

3 Answers3

1

In my case I was using a custom Auth Guard that extended the built in SessionGuard. I had to set the cookie jar myself with

$this->setCookieJar(app('cookie'));

YMMV.

Kris
  • 159
  • 3
0

I fixed this problem for myself by putting 'driver' => 'session' under guards array in config/auth.php. But I was using different guard for admin panel authentication, so it might just be that you have this misconfigured as well.

Dharman
  • 30,962
  • 25
  • 85
  • 135
davisdev
  • 73
  • 8
0

I got the same error in my case when I used a custom guard. Calling setCookieJar, setDispatcher and setRequest on my guard solved the problem. Look at this example

AID
  • 124
  • 5