Skip to content

Commit 19e8538

Browse files
author
Sergey Matvienko
committed
Fix for Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time
1 parent 80ff0d2 commit 19e8538

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

lib/config/config/factories.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ default:
2929
user:
3030
class: myUser
3131
param:
32-
timeout: 1800
3332
logging: %SF_LOGGING_ENABLED%
3433
use_flash: true
3534
default_culture: %SF_DEFAULT_CULTURE%
@@ -38,6 +37,7 @@ default:
3837
class: sfSessionStorage
3938
param:
4039
session_name: symfony
40+
timeout: 1800
4141

4242
view_cache_manager:
4343
class: sfViewCacheManager

lib/storage/sfSessionStorage.class.php

+11
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ public function initialize($options = null)
6868
// initialize parent
6969
parent::initialize($options);
7070

71+
if (!array_key_exists('timeout', $this->options))
72+
{
73+
$this->options['timeout'] = 1800;
74+
}
75+
7176
// set session name
7277
$sessionName = $this->options['session_name'];
7378

@@ -90,6 +95,12 @@ public function initialize($options = null)
9095
session_cache_limiter($this->options['session_cache_limiter']);
9196
}
9297

98+
// force the max lifetime for session garbage collector to be greater than timeout
99+
if (ini_get('session.gc_maxlifetime') < $this->options['timeout'])
100+
{
101+
ini_set('session.gc_maxlifetime', $this->options['timeout']);
102+
}
103+
93104
if ($this->options['auto_start'] && !self::$sessionStarted)
94105
{
95106
session_start();

lib/user/sfBasicSecurityUser.class.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This file is part of the symfony package.
55
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
66
* (c) 2004-2006 Sean Kerr <sean@code-box.org>
7-
*
7+
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
1010
*/
@@ -42,7 +42,7 @@ public function clearCredentials()
4242

4343
/**
4444
* Returns the current user's credentials.
45-
*
45+
*
4646
* @return array
4747
*/
4848
public function getCredentials()
@@ -248,13 +248,8 @@ public function initialize(sfEventDispatcher $dispatcher, sfStorage $storage, $o
248248

249249
if (!array_key_exists('timeout', $this->options))
250250
{
251-
$this->options['timeout'] = 1800;
252-
}
253-
254-
// force the max lifetime for session garbage collector to be greater than timeout
255-
if (ini_get('session.gc_maxlifetime') < $this->options['timeout'])
256-
{
257-
ini_set('session.gc_maxlifetime', $this->options['timeout']);
251+
$storageOptions = $storage->getOptions();
252+
$this->options['timeout'] = isset($storageOptions['timeout']) ? $storageOptions['timeout'] : 1800;
258253
}
259254

260255
// read data from storage

0 commit comments

Comments
 (0)