[Catalyst] Returning to referer - which action to take?
Ekki Plicht (DF4OR)
ep at plicht.de
Sun Sep 26 19:38:11 GMT 2010
In my app I use I18N, so the visitor should be able to select his or her
language at will. The available languages are available on all pages for
selection. Once selected the preferred language is stored in a session cookie,
otherwise the automatic mechanism of I18N uses the preferred language set in
the request header (if any)
Imagine that currently page
is displayed in english. Now visitor clicks on
the internal variable for language is set. This normally involves per-user
session management and cookies. Now I want to display the very same page
(/foo/1/bar/2) but in german.
Serving the pages in different languages works fine with C::P::I18N, but I
can't figure out how to return the visitor to the refering page. Simply
redirecting to the referer does not work, because a prepared cookie isn't
preserved over a redirect (isn't it?).
My next idea was to $c->detach() to the path part of the referer. Looking at
the request class I am surprised to find that there is no easy way to extract
the path from the referer. That made me think that my approach is probably
wrong or stupid or dangerous or all three of them.
So how is this properly done, returning a vsitor to the refering page, but
allowing cookies or preserving the stash?
More information about the Catalyst