The problem with relying on old session files is that it then becomes complicated to clean them up, because you don't know how long you need to keep them. Another option might be to store the data in the database in between sessions (much like the way the Auth user record is persisted in the database but then copied to the session upon login). Depending on the structure of the data, you could store it in a JSON field or in a custom field using pickle.
Anthony On Friday, September 11, 2015 at 10:04:40 AM UTC-4, mweissen wrote: > > I need to restore a session without using cookies: the messenger from > telegram.org offers an interesting API to create a message bot. It's very > simple to send and to receive a single message. But if I want to create a > dialog with severals questions and answers I have I problem: I need to save > my actual session during the first conversion and during the next round I > want to reuse this session. > > One idea: I store the session_filename with something like > > cache.disk(telegram_user_id, lambda: response.session_filename) > > and during the next round I can restore the session with > > filename=cache.disk(telegram_user_id, lambda: response.session_filename) > session=pickle.load(open(filename,'rb')) > > > *My questions:* > > 1. Is it sufficient to restore the session variable in this way or are > there any side effects? > 2. There are two disk accesses (one for the cache.disk, one for the > open(filename)). It's not possible to use cache.ram because web2py is > running on a virtual server. Is there any better solution? > 3. The real filename is longer, like ...app/sessions/*012/abc*/127.0.0.1-..., > but response.file_name shows only the main part > ...app/sessions/127.0.0.1-... How to get the whole filename? > 4. Is it possible and is it a better solution to store the whole > session-variable in cache.disk? > > ​Regards, Martin > -- 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.

