hook 'before_template_render' => sub { my $tokens = shift; if( session('username') ) { $tokens->{'username'} = session('username'); $tokens->{'is_admin'} = 1 if session('is_admin'); } my $global_tokens = $global{tokens}; while(my($key, $value) = each %$global_tokens) { $tokens->{$key} = $value unless exists $tokens->{$key}; } };