[dancer-users] get session info without route

David Precious davidp at preshweb.co.uk
Tue Sep 10 15:24:45 BST 2013


On Tue, 10 Sep 2013 16:05:47 +0200
Hugues Max <huguesmax at gmail.com> wrote:

> Please see my hook ( here numclient = 366 )
> 
> 
> hook 'before' => sub {
>       var numclient => session 'numclient';
>      debug "session numclient ". session 'numclient';;
>      debug "vars in hook ".vars->{'numclient'};
> };
> 
> debug "vars out hook" . vars->{'numclient'};

vars only exists within a request.  Using it outside of a request (i.e.
not in a route handler or suitable hook) is meaningless.

Try e.g.

  hook before => sub {
      var pathxls =>  config->{'PATHXLS'} . session 'numclient';
  };

  get '/outils' => sub {
      # you can use vars->{pathxls} in your route handler, e.g.
      my $pathxls = vars->{pathxls};
  };



-- 
David Precious ("bigpresh") <davidp at preshweb.co.uk>
http://www.preshweb.co.uk/     www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan        www.preshweb.co.uk/github




More information about the dancer-users mailing list