hivesolutions / appier

Joyful Python Web App development
http://appier.hive.pt
Apache License 2.0
126 stars 22 forks source link

Support for extending Appier sessions #11

Closed tsilva closed 8 years ago

tsilva commented 8 years ago

Description

There seems to be no friendly way of extending an Appier session. In some contexts, it's desirable to be able to extend the session indefinitely.

Solution

The expiration date is being set when the session object is being created. This date can be changed only by accessing the internal property directly. Probably there should be an refresh() method to easily refresh the session's expiration date (current date + default timeout).

Also, in RedisSession values are being stored with SETEX, therefore they are deleted by Redis when the timeout is reached. To extend the session in RedisSession, the value's expiration date must be extended using the EXPIRE command to provide a new timeout.

joamag commented 8 years ago

@tsilva you just need to mark the session as dirty, the rest will just work. Do self.session.mark() and see if the session is not extended...

joamag commented 8 years ago

you can now extend session by using explicitly self.session.mark(extend = True) or by setting any value in the session

joamag commented 8 years ago

Closing this ticket as support now exists for extending session