I want server side global variables that can be accessed and managed by multiple clients???
For Ex--
A user opens the game in browser and assign value to a variable then all other user playing that game see the change in value of
that variable.
server side global variables that can be accessed and manage
Moderator: General Moderators
Re: server side global variables that can be accessed and ma
PHP operates in a stateless environment by default. Even for a single user, nothing is remembered from page request to page request unless you make it happen. For a single user, you could use cookies or session variables--but they do not apply to multiple users. Storing data to be shared across multiple users must be done in a database or in a file that you write to and read from. When a user requests a page, you access the current state of your "global" data and make it available in whatever way needed when you serve up the resulting page to the user's client-based device.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: server side global variables that can be accessed and ma
On the web, that means a shared data source. Simplest would be a database, but for better performance you could use on of many in-memory solutions like Memcache to shared data this.grvpal14 wrote:I want server side global variables that can be accessed and managed by multiple clients???
The second decision is whether you want to poll or push the data. There are a number Javascript solutions to help with this, from simple Ajax calls to sockets like chat clients use.
(#10850)