Q: response.flash or session.flash?

It’s simple, just use response.flash in the normal cases [there’s no redirection]

def index():
    response.flash = T('yes yes')
    return dict()

If you’re going to redirect user from one page to another, then you’ve to use session.flash = ….. because it’s the easiest way to keep the message across multiple requests.

def index():
    session.flash = T('yes yes')
    redirect(URL(request.application, 'default', 'function2'))
    eturn dict()

As you see : using response.flash is not correct because the user is going to be redirected which means another request and another response.

In fact, when a page is loaded if there is a session.flash it is copied into response.flash (so that it is displayed) and then reset to None
why resetting session.flash to None ? so that message is displayed only once.

So what if I’m going to do redirect then redirect again? how could I keep the flash message so that it’s displayed after the last redirection?

If you redirect and redirect again the message is lost unless before the second redirection you to


2 Responses to session/response.flash

  1. Sr.Azote says:

    Oh man, thanks. This was great. God bless u.

  2. Sr.Azote says:

    lol this wasn’t the post i’m greatful about, was the one to reset the id of the tables.

    anyway, thanks man

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: