[Dancer-users] (resending) hello! (and cookie weirdness)
Alex Knowles
alexk at moonfruit.com
Wed Feb 9 18:42:46 CET 2011
Apologies if this arrives twice - I realised I hadn't confirmed my
subscription when I first sent it...
Hi all,
Just signed up, we're just starting to use Dancer - so far it's all
being awesome.
However :)
I hit a bit of a weird thing today - it's probably me misreading
something.
If I do this:
set_cookie 'blah'=> "blah", expires => (time + 3600);
as per the docs here:
http://search.cpan.org/~sukria/Dancer-1.3003/lib/Dancer.pm#set_cookie
the next time you visit it does a comparison in
Dancer::Cookies::has_changed to see if it's been updated.
The value it's checking against in this case is:
['blah'], which is then compared to "blah" and obviously aren't equal
it then drops a replacement with 'blah', but missing the expiry -
causing the cookie to expire immediately.
either of these patches will work:
+++ Cookies.pm 2011-02-09 17:30:11.000000000 +0000
@@ -40,6 +40,7 @@
sub has_changed {
my ($self, $cookie) = @_;
my ($name, $value) = ($cookie->{name}, $cookie->{value});
+ $value=$value->[0] if ref $value eq "ARRAY";
or
+++ Cookies.pm 2011-02-09 17:31:14.000000000 +0000
@@ -39,7 +39,7 @@
# return true if the given cookie is not the same as the one sent by
the client
sub has_changed {
my ($self, $cookie) = @_;
- my ($name, $value) = ($cookie->{name}, $cookie->{value});
+ my ($name, $value) = ($cookie->{name}, $cookie->value);
or maybe it's something in Dancer::Renderer, or Dancer::Cookie...
Am I on the right track? or have I done something wrong in my cookie
setting?
cheers.
Alex
More information about the Dancer-users
mailing list