>From 13be47e3be8e0fabb7124165042c3fc6adbd1a19 Mon Sep 17 00:00:00 2001 From: Jens Rehsack Date: Thu, 27 Dec 2012 16:11:43 +0100 Subject: [PATCH 1/2] add ability to modify session path (restrict session to a sub-site) --- 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)