<div dir="ltr">Thanks, it was something stupidly simple. No idea what the domain is either but I don't care as long as the thing sets and sets with a very very long expiry.<div><br></div><div>cookie user => $thing, expires => '+2000h';<br></div><div><br></div><div>Did it. </div><div><br></div><div>Thanks again,</div><div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 20, 2015 at 5:53 PM, Andrew Beverley <span dir="ltr"><<a href="mailto:andy@andybev.com" target="_blank">andy@andybev.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, 2015-08-20 at 09:08 +0930, David H wrote:<br>
> I've tried setting my own cookie with Dancer2 and also setting the session<br>
> engine as Cookie.<br>
</span>...<br>
<span class="">> Although I couldn't find a lot on the Dancer2 method, there is a bit on how<br>
> to do this with Dancer1.<br>
><br>
> I have this in my config.yml (thanks Andrew for the help with this):<br>
> template: "template_toolkit"<br>
> session: Cookie<br>
> engines:<br>
>    template:<br>
>      template_toolkit:<br>
>        start_tag: '<%'<br>
>        end_tag:   '%>'<br>
>    session:<br>
>      Cookie:<br>
>        secret_key: mykey<br>
>        default_duration: 60480064<br>
><br>
> However when the session is created, as per this image below, the session<br>
> expiry is still 'session' instead of the time I set, which should be<br>
> roughly.<br>
<br>
</span>I've not used Dancer2::Session::Cookie, but I know the following works for the<br>
YAML session engine. Therefore, it might be worth trying the generic<br>
cookie_duration parameter instead:<br>
<br>
engines:<br>
  session:<br>
    YAML:<br>
      session_dir: "/tmp/dancer-sessions"<br>
      cookie_duration: 3600<br>
<span class=""><br>
> I've had a look at the cookie tests but I still can't figure out how to<br>
> work with cookies properly in Dancer2. The date I set should set the<br>
> session cookie to around 2130. I've also tried lower times with no effect.<br>
<br>
</span>To set a cookie:<br>
<br>
    cookie MYCOOKIE => 'value', expires => '+2h', domain => $cookie_domain;<br>
<br>
(I guess the domain is optional - I've just copied that from existing code)<br>
<br>
To get a cookie:<br>
<br>
    my $code = cookie 'MYCOOKIE'<br>
<br>
Regards,<br>
<br>
Andy<br>
<br>
<br>
_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" rel="noreferrer" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
</blockquote></div><br></div>