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

stocksph's avatar

Not to use Session for unregistered visitors

Hi, I noticed that for every visitors(registered & unregistered) are generating a session file @ storage/framework/session directory.

I was wondering if there's a way to not to use session for unregistered visitors? Coz for a heavy traffic website(specially visitors from search engine results are generating a session file), this will affect server performance.

Is it possible not to use session on unregistered visitors? Any help is highly appreciated.

Sincerely, StocksPH

0 likes
5 replies
ouhare's avatar

check the web middleware group, one of them create the session.

Dan's avatar

@stocksph It's not recommended to use the file session driver in production for the very reason you outline. Look into possibly using the Redis or Memcached driver instead.

martinbean's avatar

@stocksph As @ouhare mentions, remove the routes from the “web” middleware group.

Be warned though: if these pages have login/logout links, then they’ll always says “login” as without the session, you won’t know if a user is logged in or not. If this is the case, you will need to look at a session driver other than the default file one.

Please or to participate in this conversation.