Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable session in Laravel

I am developing stateless resful API application, so I do not need sessions at all.

I removed a line with \Illuminate\Session\Middleware\StartSession::class, from protected $middleware = []; in \app\Http\Kernel.php I have also removed SESSION_DRIVE from .env file. But I am getting following error:

RuntimeException in Request.php line 756: Session store not set on request.

How can I turn off sessions in Laravel 5?

like image 915
user1292810 Avatar asked Jul 23 '15 13:07

user1292810


People also ask

How do I stop a laravel session?

$request->session()->forget('key'); Use flush() method instead of forget() method to delete all session data. Use the pull() method to retrieve data from session and delete it afterwards.

How can I change session in laravel?

The correct syntax for this is: Session::set('variableName', $value); For Laravel 5.4 and later, the correct method to use is put : Session::put('variableName', $value);

What is session in laravel?

Laravel session is a way of storing the user information across the multiple user requests. It keeps track of all the users that visit the application. Let's understand the session through an example. First, we create a form on which we apply the properties of the session.

What is laravel default session timeout?

By default in laravel application session timeout value is 120 minutes.


1 Answers

Remove the Illuminate\Foundation\Http\Middleware\VerifyCsrfToken and Illuminate\View\Middleware\ShareErrorsFromSession classes from your middleware too. These features require sessions.

Not required but I'd also probably suggest setting your session driver to array, just so that if any features you are using require the sessions feature they can at least work without throwing errors. The array driver, as it suggests, stores all the session data in a standard PHP array so everything is erased as soon as the request is completed.

like image 169
Wader Avatar answered Oct 05 '22 09:10

Wader