summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--framework/Web/THttpSession.php5
-rw-r--r--tests/unit/Web/THttpSessionTest.php30
2 files changed, 31 insertions, 4 deletions
diff --git a/framework/Web/THttpSession.php b/framework/Web/THttpSession.php
index 79c6e6df..b96a977e 100644
--- a/framework/Web/THttpSession.php
+++ b/framework/Web/THttpSession.php
@@ -297,8 +297,11 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
else
{
$value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode');
- if($value===THttpSessionCookieMode::None)
+ if($value===THttpSessionCookieMode::None)
+ {
ini_set('session.use_cookies','0');
+ ini_set('session.use_only_cookies','0');
+ }
else if($value===THttpSessionCookieMode::Allow)
{
ini_set('session.use_cookies','1');
diff --git a/tests/unit/Web/THttpSessionTest.php b/tests/unit/Web/THttpSessionTest.php
index aca83077..eb1ec4df 100644
--- a/tests/unit/Web/THttpSessionTest.php
+++ b/tests/unit/Web/THttpSessionTest.php
@@ -43,8 +43,32 @@ class THttpSessionTest extends PHPUnit_Framework_TestCase {
throw new PHPUnit_Framework_IncompleteTestError();
}
- public function testSetCookieMode() {
- throw new PHPUnit_Framework_IncompleteTestError();
+ public function testSetCookieModeNone() {
+ $session = new THttpSession();
+ $session->CookieMode = THttpSessionCookieMode::None;
+
+ $this->assertEquals(0, ini_get('session.use_cookies_only'));
+ $this->assertEquals(0, ini_get('session.use_cookies'));
+ $this->assertEquals(THttpSessionCookieMode::None, $session->CookieMode);
+ }
+
+ public function testSetCookieModeAllow() {
+ $session = new THttpSession();
+ $session->CookieMode = THttpSessionCookieMode::Allow;
+
+ $this->assertEquals(0, ini_get('session.use_only_cookies'));
+ $this->assertEquals(1, ini_get('session.use_cookies'));
+ $this->assertEquals(THttpSessionCookieMode::Allow, $session->CookieMode);
+ }
+
+ public function testSetCookieModeAlways() {
+ $session = new THttpSession();
+ $session->CookieMode = THttpSessionCookieMode::Only;
+
+ $this->assertEquals(1, ini_get('session.use_only_cookies'));
+ $this->assertEquals(1, ini_get('session.use_cookies'));
+ $this->assertEquals(0, ini_get('session.use_trans_sid'));
+ $this->assertEquals(THttpSessionCookieMode::Only, $session->CookieMode);
}
public function testSetAutoStart() {
@@ -110,4 +134,4 @@ class THttpSessionTest extends PHPUnit_Framework_TestCase {
public function testOffsetUnset() {
throw new PHPUnit_Framework_IncompleteTestError();
}
-} \ No newline at end of file
+}