开发者

is there any way to forbidden session write to file

开发者 https://www.devze.com 2023-01-13 21:25 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消