passing session user name from route sub to route sub
When a user signs in I do this to send them to their page with log in. # Logged in successfully session username => $input_hash->{FName}; redirect '/userpage'; However, I am wondering how I can pass the username from on sub to another sub call within my MyApp.pm. So that as a user bounces to another page I can do a database query for that user. For example, if the user goes to. get '/JobsView' => sub { #query open jobs for the user } How do I get the username inside '/JobsView' so that I can use it for SQL queries? Thanks
On Mon, Aug 24, 2015 at 9:51 PM, Richard Reina <gatorreina@gmail.com> wrote:
When a user signs in I do this to send them to their page with log in.
# Logged in successfully session username => $input_hash->{FName}; redirect '/userpage';
However, I am wondering how I can pass the username from on sub to another sub call within my MyApp.pm. So that as a user bounces to another page I can do a database query for that user. For example, if the user goes to.
get '/JobsView' => sub {
#query open jobs for the user
}
How do I get the username inside '/JobsView' so that I can use it for SQL queries?
Thanks
You should be able to access it with the same session keyword: get '/JobsView' => sub { my $username = session 'username'; #query open jobs for the user } -Naveed
participants (2)
-
Naveed Massjouni -
Richard Reina