tags:

views:

26

answers:

2

if I know Session data is not changed , So I don't want session write to file again. but it seems impossible, because session will automatic write after php script shutdown.

register_shutdown_function doesn't help, any ideas?

A: 

Write a custom session handler which, in its session_commit() handler, checks for the existence of the "Don't overwrite me" flag and returns early if it's there. See http://php.net/session-set-save-handler for a good starting framework for writing your own handler based on PHP's built-in file-based handler.

TML
A: 

You can roll your own session handler, of course, and keep track of changes and only update the storage medium (file, database, army of trained monkeys with whiteboards, ...) if something's changed.

But with the standard file-based system, not really. That's in PHP's hands.

Marc B