Just found the solution. Looking at the source of auth.logout() at 
http://web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#Auth.logout,
 
there is a line here: 


        current 
<http://web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>.session
 
<http://web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>.flash 
= self.messages.logged_out 


which looks like the cause of session.flash being assigned None.

On chapter 9 of the book (http://web2py.com/books/default/chapter/29/9), 
there is a bunch of auth.messages that can be customized, such as the one 
for logging out:

auth.messages.logged_out = T('You are logged out.')


Now session.flash (actully response.flash after the redirect) will have 
whatever message I set. 


On Wednesday, 7 March 2012 00:02:08 UTC, danny wrote:
>
> Hello. I'm trying to customize the login and register forms as follows:
>
>    - user() function does not return auth(), instead display two forms 
>    separately like this:
>
>       {{if not auth.is_logged_in():}}
>       {{login_form = auth.login()}}
>       {{=login_form.custom.begin}}
>       ...
>       {{=login_form.custom.submit}}
>       {{=login_form.custom.end}}
>
>       {{reg_form = auth.register()}}
>       {{=reg_form.custom.begin}}
>       ...
>       {{=reg_form.custom.submit}}
>       {{=reg_form.custom.end}}
>       {{pass}}
>
>    - Inside user() function it logs the user out manually when "http
>    ://.../[app]/default/user/logout" is requested:
>    
>     if request.args(0) == 'logout':
>         session.flash = T('You are logged out.')
>         auth.logout()
>
> Everything works except session.flash is wiped clean when auth.logout() 
> automatically redirects to default/index. How can I keep session.flash 
> after redirect? Thanks.
>

Reply via email to