2

I'm trying to fetch data from sessions when I run a command in my console, but session always returns an empty array!

php artisan command:mycommand

Below is how I'm trying to get the session:

//returns empty array
$session = session()->all();

Any ideas?

shaedrich
  • 5,457
  • 3
  • 26
  • 42
Ricardinho
  • 599
  • 9
  • 22

1 Answers1

1

Session are used in the context of HTTP protocol. There is no such session using CLI. However, if your php artisan command is triggered in the context of an HTTP request, you could pass data to your command using arguments.