I'm trying to check it a session key has already been set inside a controller. The documentation states that it is possible to check if an item exists in an array and that's it.
http://laravel.com/docs/5.1/session
You can check whether a variable has been set in a user's session using the function isset(), as you would a normal variable. Because the $_SESSION superglobal is only initialised once session_start() has been called, you need to call session_start() before using isset() on a session variable.
To determine if an item is present in the session, you may use the has method. The has method returns true if the item is present and is not null. To determine if an item is present in the session, even if its value is null, you may use the exists method.
Sessions are used to store information about the user across the requests. Laravel provides various drivers like file, cookie, apc, array, Memcached, Redis, and database to handle session data. By default, file driver is used because it is lightweight. Session can be configured in the file stored at config/session.
you can use
if($request->session()->has('key'))
{
}
Has pointed out by @DavidDomain probably the best way of doing it is to use
if(Session::has('...'))
Worked like a charm for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With