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?
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.
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.
精彩评论