[dancer-users] get session info without route

Stefan Hornburg (Racke) racke at linuxia.de
Tue Sep 10 11:47:15 BST 2013


On 09/10/2013 11:03 AM, Hugues Max wrote:
> Hello
> I use Dancer 1.3118 with YAML session in config.
>
> session: 'YAML' in config.yml
>
>
> in my file.pm
> I try to use
>
> my $PATHXLS  = config->{'PATHXLS'}. session 'numclient' .'/';
>
> if this ligne is in any route (get , post, any .. ) it's working for this route
>
> but if this line is at beginning of file,  outside of route  , and I want to use $PATHXLS,  info of session 'numclient' is empty
>
> I tried to use hook 'before'
>
> my $PATHXLS;
> hook 'before' => sub {
>      $PATHXLS  = config->{'PATHXLS'}. session 'numclient' .'/';
> };
>
> debug $PATHXLS;
>
>
> but this is the same problem , $PATHXLS is defined but without session info
>
> do you have a idea  to get a variable for all file with session info ?
> bye
> Hugues.
>

Session should work within "before" hook. It is better to use vars (valid through the current request)
to store this type of information.

Regards
            Racke

-- 
Perl and Dancer Development

Visit our Open Source conference on E-commerce:

http://www.ecommerce-innovation.com/


More information about the dancer-users mailing list