tags:

views:

32

answers:

2

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.

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

+1  A: 

Just use a database table for storing that value.

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

Artefacto
+2  A: 

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.

Pekka
Your last phrase is actually he shouldn't actually use anything but a database. That's a solved problem there. The methods available to the other solutions don't scale anywhere as well.
Artefacto
@Artefacto yup, true. File locking is a pain. He may not want or be able to use a database, though.
Pekka
@Nikunj no, this is impossible using only PHP variables. Session variables can't be shared across users.
Pekka
and Pekka, what's memcache bucket?? i mean link to get idea about it?
Nikunj Kotecha
@Nikunj http://www.php.net/memcache but it requires a specific module installed in PHP. If you can't use files or databases, a memcache based solution is probably even less desired
Pekka
thanx for the quick reply... :)
Nikunj Kotecha