Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updating Session path handling to fix cases when path = ''.

Test cases added.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8186 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 7401b0c70f103f16afa51fd720be31d09d833a68 1 parent d2b4995
@markstory markstory authored
Showing with 14 additions and 5 deletions.
  1. +8 −5 cake/libs/session.php
  2. +6 −0 cake/tests/cases/libs/session.test.php
View
13 cake/libs/session.php
@@ -137,20 +137,23 @@ function __construct($base = null, $start = true) {
$this->time = time();
if ($start === true) {
- $this->host = env('HTTP_HOST');
- $this->path = '/';
- if (strpos($base, '?') === false && strpos($base, 'index.php') === false) {
+ if (!empty($base)) {
$this->path = $base;
+ if (strpos($base, 'index.php') !== false) {
+ $this->path = str_replace('index.php', '', $base);
+ }
+ if (strpos($base, '?') !== false) {
+ $this->path = str_replace('?', '', $base);
+ }
}
+ $this->host = env('HTTP_HOST');
if (strpos($this->host, ':') !== false) {
$this->host = substr($this->host, 0, strpos($this->host, ':'));
}
-
if (!class_exists('Security')) {
App::import('Core', 'Security');
}
-
$this->sessionTime = $this->time + (Security::inactiveMins() * Configure::read('Session.timeout'));
$this->security = Configure::read('Security.level');
}
View
6 cake/tests/cases/libs/session.test.php
@@ -76,6 +76,12 @@ function setUp() {
function testSessionPath() {
$Session = new CakeSession('/index.php');
$this->assertEqual('/', $Session->path);
+
+ $Session = new CakeSession('/sub_dir/index.php');
+ $this->assertEqual('/sub_dir/', $Session->path);
+
+ $Session = new CakeSession('');
+ $this->assertEqual('/', $Session->path, 'Session path is empty, with "" as $base needs to be / %s');
}
/**
* testCheck method
Please sign in to comment.
Something went wrong with that request. Please try again.