[Dancer-users] flash implementation
Иван Бессарабов
ivan at bessarabov.ru
Thu Dec 30 08:37:12 CET 2010
Hi!
I've read http://advent.perldancer.org/2010/3 and I have a question.
In the blog implementation, described in the article there is so called "flash".
There is a global variable where one stores some message that is
available after redirect:
my $flash;
sub set_flash { $flash = shift }
sub get_flash { my $msg = $flash; $flash = ""; return $msg } )
post '/add' => sub {
# some lines skipped
set_flash('New entry posted!');
redirect '/';
};
I think there can be a problem with this thing: if there are a lot of
requests to the site some user can see the flash message that was done
for some other user.
Am I right?
I can see several ways of doing the same way but in more safe way:
1. redirect to page with parameter that identifies flash message (have
a problem with not pretty urls)
2. store id to flash message in a cookie
3. store flash message in a session
Any other ways?
More information about the Dancer-users
mailing list