---
title: "Comment by Kamran Khan on \"Reading the Laravel Session Without Saving It\" | Hashnode"
description: "The clearest writeup of this race I've read — \"every request in the web group is a writer\" is the sentence that makes the whole thing click. One caveat I'd add"
url: "https://hashnode.com/posts/reading-laravel-session-without-saving/6ace74f8ccae093f439d6a5b/comment/6ad2280a01c4b34da625d01d"
---

[Discussion](https://hashnode.com/posts/reading-laravel-session-without-saving/6ace74f8ccae093f439d6a5b)

Comment [Reading the Laravel Session Without Saving It](https://hashnode.com/posts/reading-laravel-session-without-saving/6ace74f8ccae093f439d6a5b)

[Kamran Khan](https://hashnode.com/@kamrankhandev)

[Oct 16](https://hashnode.com/posts/reading-laravel-session-without-saving/6ace74f8ccae093f439d6a5b/comment/6ad2280a01c4b34da625d01d)

The clearest writeup of this race I've read — "every request in the web group is a writer" is the sentence that makes the whole thing click.

One caveat I'd add to your honest-details list: never put this middleware on a route that regenerates or invalidates the session. `logout()` calls `$this->session->invalidate()`, which destroys the old session row and writes a fresh empty one — with the `NullSessionHandler`, both the destroy and the write are discarded. The browser gets the new session cookie, but the old session stays valid server-side for its full lifetime. Logout would look successful while the session quietly survives.

Same applies anywhere you call `regenerate()`. The middleware is strictly for read-only routes; anything that mutates session identity needs the real handler. Worth a line in the post, because "apply it broadly to stop races" is the tempting misreading.

[Ubeydullah Keleş](https://hashnode.com/@ubeyd)

[Oct 16](https://hashnode.com/posts/reading-laravel-session-without-saving/6ace74f8ccae093f439d6a5b/comment/6ad2280a01c4b34da625d01d#reply-6ad229ef222f533a6f24122f)

Thanks for your addition [Kamran Khan](https://hashnode.com/@kamrankhandev "Kamran Khan")
