[Catalyst] Limiting flash to a specific request

Bill Moseley moseley at hank.org
Fri Oct 12 18:23:00 GMT 2007


The "flash" session store is handy for displaying messages for a
redirect-after-post.  But, there's nothing to guarantee that the
message goes to the right client instance (e.g. the user has multiple
windows open).

Perhaps this is wandering back into the "sub-sessions" and continuations
discussions, but I'm curious if anyone is using some method such as an
additional query parameter to make sure that the data in the flash
is going to the correct browser window.

Perhaps something like:

    $c->stash->{message} = 'Record Updated';

    $c->persist_stash( qw/ message first_name other_stash_thing / );
    $c->res->redirect( $c->uri_for( 'list' ) );

And then in some finalize action place the stash items listed in the
session based on some unique request ID and alter $c->res->redirect to
include the request ID.

    Location:  http://localhost:3000/foo/list?rid=abcde

Then early in the request watch for the request id and when found
initialize the stash with the saved items in the session.


Is anyone doing something like this currently?  If so, I'm curious
about the implementation.

- How do you decided when an item stored this way is stale?
  My initial implementation looks for and removes "old" items
  when adding new items into the persistent stash.

- What do you do if a request comes in with a "request id"
  that is not found in the session?  (Similar problem to
  a continuation request with an invalid continuation id.)




BTW -- I looked at the Continuation plugin and, like others have
commented, don't really get the docs.  Plus, I don't really need to
restore the entire context.  So, I'm not sure if that's a solution.



-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list