I'm not sure there is any need to clean up individual sessions unless you 
are storing a large amount of data. On the other hand, you might want to 
clean up expired session files once in a while -- there is a script for 
that.

Anthony

On Tuesday, November 3, 2015 at 1:43:47 PM UTC-5, Richard wrote:
>
> Hello,
>
> Let say I put some data in session.var1 for reuse in case user want to 
> download the content of the page with the help of buttons for the purpose 
> which call the same function with one more prameter telling the controller 
> function which file format the user expect...
>
> So you can check if file format parameter is there and pass the 
> session.var1 to the sub funciton :
>
> if request.vars.file_format:
>     export_to_file(session.var1)
> else:
>     del(session.var1)  # Here I can't delete var1 from session in case a 
> new call is made to the controller for the first time...
>
> But, what to do with session.var1 in case the which will remain there if I 
> load any other app pages??
>
> Should I create a clean_up_session()?
>
> Something like this :
>
> def clean_up_session():
>     if session.var1 and request.function != 'my_controller_func' and not 
> request.vars.file_format:
>         del(session.var1)
>
> Which I would need to executed at every request (can't be put in model 
> file for that purpose)...
>
> But I am curious what is consider the best practices regarding session 
> variables ?
>
> Thanks
>
> Richard
>

-- 
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