server side global variables that can be accessed and manage

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
grvpal14
Forum Newbie
Posts: 1
Joined: Sat Feb 14, 2015 7:41 am

server side global variables that can be accessed and manage

Post by grvpal14 »

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.
phpRob
Forum Newbie
Posts: 9
Joined: Thu Feb 12, 2015 3:45 pm

Re: server side global variables that can be accessed and ma

Post by phpRob »

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.
User avatar
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

Post by Christopher »

grvpal14 wrote:I want server side global variables that can be accessed and managed by multiple clients???
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.

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)
Post Reply