开发者

php share variable among different users/sessions

i want to have a variable that has the same value for all the different us开发者_运维技巧ers/clients accessing the system.

also the variable's value has to be modifiable.

like if any one user changes the value, the change has to get reflected to all other users too.


Store the variable in a shared space like

  • A file

  • A database record (easiest for implementing locking, see below)

  • A memcache bucket

you can easily modify it there. You may need to use some sort of locking mechanism to prevent race conditions when multiple users try to edit the value at the same time.


Just use a database table for storing that value.

That's the simplest way to store persistent application-wide data in a Web application.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜