[PATCH 1/2] add ability to modify session path (restrict session to a sub-site)
Jens Rehsack
sno at netbsd.org
Thu Dec 27 15:11:43 GMT 2012
---
lib/Dancer/Session/Abstract.pm | 1 +
t/08_session/15_session_path.t | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
create mode 100644 t/08_session/15_session_path.t
diff --git a/lib/Dancer/Session/Abstract.pm b/lib/Dancer/Session/Abstract.pm
index e986780..319e601 100644
--- a/lib/Dancer/Session/Abstract.pm
+++ b/lib/Dancer/Session/Abstract.pm
@@ -93,6 +93,7 @@ sub write_session_id {
value => $id,
domain => setting('session_domain'),
secure => setting('session_secure'),
+ path => setting('session_path'),
http_only => defined(setting("session_is_http_only")) ?
setting("session_is_http_only") : 1,
);
diff --git a/t/08_session/15_session_path.t b/t/08_session/15_session_path.t
new file mode 100644
index 0000000..eb7885f
--- /dev/null
+++ b/t/08_session/15_session_path.t
@@ -0,0 +1,34 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Dancer ':syntax', ':tests';
+use Dancer::Session::Simple;
+use Test::More tests => 2;
+
+
+my $Session_Name = Dancer::Session::Simple->session_name;
+
+note "session_domain off"; {
+ set session => "simple";
+ session foo => "bar";
+
+ my $session_cookie = Dancer::Cookies->cookies->{ $Session_Name };
+ is $session_cookie->path => "/";
+}
+
+
+note "session_domain on"; {
+ delete Dancer::Cookies->cookies->{ $Session_Name };
+
+ my $test_path = '/test/app';
+
+ set session => "simple";
+ set session_path => $test_path;
+
+ session up => "down";
+
+ my $session_cookie = Dancer::Cookies->cookies->{ $Session_Name };
+ is $session_cookie->path => $test_path;
+}
--
1.7.10.2 (Apple Git-33)
--------------070704020003070300070502
Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0";
name="0002-use-methods-not-package-functions.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="0002-use-methods-not-package-functions.patch"
More information about the dancer-users
mailing list