Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gatakka's avatar

Is it possible to turn off session for certan request

I am wondering is there a easy way to stop DB and sessions for some specific routes. For example, there are some static pages (just blade), that are public, and have a lot of hits. DB and session are not needed there. Why to hit DB for them?

0 likes
3 replies
toniperic's avatar

It won't hit the database if you are not trying to get data from the database (probably using an Eloquent model).

gatakka's avatar

Yes, but if session is in DB, then DB query will be executed.

toniperic's avatar

You can set the session driver for those routes/controllers on the runtime, likewise:

Config::set('session.driver', 'array');
2 likes

Please or to participate in this conversation.