In my application, I am trying to save user information in a cache variable and access it in another method. I can access it inside the same method. But when I try to access out of that method, it returns null. I need to know how to achieve this, please someone help me out here with an example as I am new to the technology.
Inside a method:
Cache::set('user', $user);
Accessing it in another method:
$user = Cache::get('user');
And I want to clear it once accessing it.