Online games usually have a central server component which manages the world state. Each client communicates directly with the server. The server sends each client data about the surrounding (that's how the map looks, there is a mob A, and there is an item B) and the clients sends the server information about what it is doing (I walk to x:y; I attack mob A; I pick up item B).
In Mozilla Browserquest, this server component is programmed in NodeJS.
Regarding persisting the game state of players which are currently logged out: This should also be done on the server by storing this data in some kind of database. A possible but much worse alternative would be to store the players progress in the local Webstorage of the client (another new HTML5 feature). That would relieve the server of the responsibility, but would give players an easy opportunity to cheat, because they were able to edit their game state.