Skip to content
Free since 2014. Built for the engineers who keep things running.

cat /articles/what-phps-session-handler-teaches-us-about-atomicity-2.md

PHP

What PHP's session handler teaches us about atomicity

A look at how an interrupted write in PHP's file-based session handler can leave session data in a state that becomes a security problem. It shows why file locking alone does not make an update atomic.

freek.dev26 Nov 2026 · 1 min read · summary

article --summary

The summary

The piece walks through how PHP stores sessions in files and what happens when a write to that file is cut off partway through. Partial writes can leave session contents in a half-updated state that an attacker may be able to exploit. The author uses this case to make a broader point about atomicity: holding a lock on a file controls who can access it at a given moment, but it does not guarantee that a multi-step update either completes fully or not at all. Readers interested in concurrency, storage design, or web security will find it a concise example to learn from.

Editorial note: This is a summary of an article first published by freek.dev. The full piece is on their site.

Reading now

Topic
PHP
Source
freek.dev
Published
26 Nov 2026
Format
Curated summary

Have a take on this?

Write it up and submit it. It goes on the list once an editor approves it.

Submit an article

articles --latest

Latest articles

New from the blogs we follow and the community.

All articles

newsletter --weekly

LaraChat Weekly, minus the noise.

The best reads, new jobs and upcoming events, in one email a week.