Level 13
you can use session() helper function to check for a key in session..
if(session()->has('access_token')) { return ''; }
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
if(empty(session('access_token')) || empty(session('refresh_token')) || empty(session('token_expires'))) {
return '';
}
Is there a cleaner way to write this? are there any useful functions from the session helper that can be used?
As @BishoyWagih mentioned there is a has() function, but it also accepts an array. So you could write it as:
if (!session()->has(['access_token', 'refresh_token', 'token_expires'])) {
return '';
}
Please or to participate in this conversation.