Skip to content

Commit

Permalink
10218 - Fix for session regenerate id issue that occured after user l…
Browse files Browse the repository at this point in the history
…ogged out yiisoft#10218
  • Loading branch information
andrewnester committed Jan 19, 2016
1 parent 2f4d5ff commit ab25b8a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions framework/web/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ public function destroy()
{
if ($this->getIsActive()) {
@session_unset();
$sessionId = session_id();
@session_destroy();
@session_id($sessionId);
}
}

Expand Down
30 changes: 30 additions & 0 deletions tests/framework/web/SessionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace yiiunit\framework\web;

use yii\web\Session;
use yiiunit\TestCase;

/**
* @group web
*/
class SessionTest extends TestCase
{
/**
* Test to prove that Session::destroy generates session with new identifier
*/
public function testDestroySessionId()
{
$session = new Session();
$session->open();
$oldSessionId = @session_id();

$this->assertNotEmpty($oldSessionId);

$session->destroy();

$newSessionId = @session_id();
$this->assertNotEmpty($newSessionId);
$this->assertEquals($oldSessionId, $newSessionId);
}
}

0 comments on commit ab25b8a

Please sign in to comment.