'Laravel - How to maintain a object in different controllers?

I am new to the Laravel framework, and hopefully, someone can save my life!

So I am making a WEB application demo by using Laravel, and I use Vus as the front-end. I send the request from Vue to Laravel's controller, but I am wondering if I can maintain the object inside the controller when I finish one HTTP request, then I can still use the object's property data in another request (the request could be in the same controller or another controller)?

Especially the object I want to maintain has some properties like token and expired time, and a function inside to check if the token is expired or not. So I would like to keep these properties inside the object and just store them in the memory.

class OneController extends Controller
{
    private object $object;
    public function __consturct()
    {
       // Do something to $this->object
    }
}
class AnotherController extends Controller
{
    private object $object;
    public function __consturct()
    {
       // Do something to $this->object
    }
}

I don't know if I describe my problem clearly, so don't hesitate to tell me if you want more context!

Thank you, World!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source