[dancer-users] get session info without route
Hugues Max
huguesmax at gmail.com
Tue Sep 10 15:05:47 BST 2013
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'};
and log
[8425] debug @0.004796> [hit #1]session numclient 366 in
/home/faxexpert/DancerFx/lib/fx/outils.pm l. 25
[8425] debug @0.004964> [hit #1]vars in hook 366 in
/home/faxexpert/DancerFx/lib/fx/outils.pm l. 26
[8425] core @0.005126> [hit #1]entering before hook in
/usr/local/share/perl5/Dancer/Hook.pm l. 58
[8425] core @0.090481> [hit #1]response: 200 in
/usr/local/share/perl5/Dancer/Handler.pm l. 179
[8426] debug @0.000009> vars out hook in
/home/faxexpert/DancerFx/lib/fx/outils.pm l. 29
vars out hook is empty...
Le 10/09/2013 12:47, Stefan Hornburg (Racke) a écrit :
> 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
>
More information about the dancer-users
mailing list