I wasn't clearing the session itself, just those two variables (setting 
session.char_dict = {}, session.gamestate = ""), but your point is taken, 
especially with how poorly my current solution is working.

I can't pass around just the id (which was a previous implementation that I 
tried) because characters do not get stored in the database at all (and 
therefore don't have an id) unless the player has an account and is logged 
in. Additionally, any changes to the character are only written to the 
database when the game is saved, again requiring auth.is_logged_in(); 
turn-by-turn changes are stored in the character dict only.

On Tuesday, March 17, 2015 at 3:54:18 PM UTC-4, Leonel Câmara wrote:
>
> You should not be clearing the session anywhere except for logouts. The 
> multiple characters problem would be easy to solve if you sent the 
> character ID in each request and used a corresponding key to store in the 
> session. For instance your URL to play could be 
> mygame.com/play/character_id
>   
> You could also just try and send the character id with every request and 
> reading and writing from the database every request, it may be fast enough, 
> databases are really smart about caching nowadays so you may be prematurely 
> optimizing something that doesn't need it.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to