gennoob has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I ben using Catalyst for a while and I just have a small problem with the forwarding of data between controllers. Supposed I do the following: From my login page, I want to forward user info to my guestbook page
#(in /users/login) $c->stash->{usern} = $user; $c->forward('/guestbook/record');
This code successfully send user info to my guestbook controller, processed by the record action. However, the url on the browser still displays http://localhost:3000/users/login even if it already displays the page for my guestbook page. If I try to use
$c->res->redirect('http://localhost:3000/guestbook/record');
it does change the url but it doesn't forward user info. Is there a a proper way to forward between controllers and change the url to indicate the accessed action?

Replies are listed 'Best First'.
Re: Catalysts question
by phaylon (Curate) on Apr 20, 2006 at 09:12 UTC
      Thanks very much! Sessions did better.
Re: Catalysts question
by Corion (Patriarch) on Apr 20, 2006 at 08:26 UTC

    The only way to "change the location bar" is to issue a HTTP 301 (or HTTP 302) redirect, which, unsurprisingly, is done with the ->redirect method. This has the "drawback" of generating a second request to your server, but has the advantage that your application is guarded against users reloading a page in the browser window.

    Update: Upon readong phaylon's reply, I realized that you want to keep the user information and have no session set up yet, so before issuing the redirect, you need to create the session for the user, preferrably by one of the modules that phaylon linked to.