[dancer-users] Second cookie [ for 'remember me' username only ]

Andrew Beverley andy at andybev.com
Mon Apr 24 08:21:27 BST 2017


On Mon, 24 Apr 2017 10:25:35 +1000 Nathan Bailey wrote:
> Hi all,
>  I'd like to have a 'remember me' cookie for users who want their
> username to be remembered by the browser (but not the password).
> 
> Dancer2::Core::Role::SessionFactory's set_cookie_header seems quite
> specific to sessions, so it appears that the right/best way to do it
> is to use push_header (as set_cookie_header does), viz:
> if (is_successful_login && defined params->{remember_me} &&
> params->{remember_me}) {
>     push_header(
>         'Set-Cookie',
>         (remember_me_user => session('user'))
>    );
> }

You can just use the Dancer keyword "cookie":

  cookie 'remember_me_user' => session('user'), http_only => 1;


Regards,

Andy


More information about the dancer-users mailing list