php share variable among different users/sessions

前端 未结 2 546
暖寄归人
暖寄归人 2020-11-29 13:44

i want to have a variable that has the same value for all the different users/clients accessing the system.

also the variable\'s value has to be modifiable.

相关标签:
2条回答
  • 2020-11-29 13:46

    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 讨论(0)
  • 2020-11-29 14:11

    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.

    0 讨论(0)
提交回复
热议问题