Skip to content

Commit 28eb44c

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 19e8538 commit 28eb44c

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

lib/config/config/factories.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ default:
2929
user:
3030
class: myUser
3131
param:
32+
timeout: 1800
3233
logging: %SF_LOGGING_ENABLED%
3334
use_flash: true
3435
default_culture: %SF_DEFAULT_CULTURE%
@@ -37,7 +38,6 @@ default:
3738
class: sfSessionStorage
3839
param:
3940
session_name: symfony
40-
timeout: 1800
4141

4242
view_cache_manager:
4343
class: sfViewCacheManager

lib/config/sfFactoryConfigHandler.class.php

+6
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ public function execute($configFiles)
109109
unset($parameters['database']);
110110
}
111111

112+
$sessionGcMaxlifetime = 1800;
113+
if (isset($config['user']['timeout'])) {
114+
$sessionGcMaxlifetime = $config['user']['timeout'];
115+
}
116+
$defaultParameters[] = sprintf("'gc_maxlifetime' => %d,", $sessionGcMaxlifetime);
117+
112118
$instances[] = sprintf(" \$class = sfConfig::get('sf_factory_storage', '%s');\n \$this->factories['storage'] = new \$class(array_merge(array(\n%s\n), sfConfig::get('sf_factory_storage_parameters', %s)));", $class, implode("\n", $defaultParameters), var_export($parameters, true));
113119
break;
114120

lib/storage/sfSessionStorage.class.php

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

71-
if (!array_key_exists('timeout', $this->options))
71+
if (!array_key_exists('gc_maxlifetime', $this->options))
7272
{
73-
$this->options['timeout'] = 1800;
73+
$this->options['gc_maxlifetime'] = 1800;
7474
}
7575

7676
// set session name
@@ -96,9 +96,9 @@ public function initialize($options = null)
9696
}
9797

9898
// force the max lifetime for session garbage collector to be greater than timeout
99-
if (ini_get('session.gc_maxlifetime') < $this->options['timeout'])
99+
if (ini_get('session.gc_maxlifetime') < $this->options['gc_maxlifetime'])
100100
{
101-
ini_set('session.gc_maxlifetime', $this->options['timeout']);
101+
ini_set('session.gc_maxlifetime', $this->options['gc_maxlifetime']);
102102
}
103103

104104
if ($this->options['auto_start'] && !self::$sessionStarted)

lib/user/sfBasicSecurityUser.class.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ public function initialize(sfEventDispatcher $dispatcher, sfStorage $storage, $o
248248

249249
if (!array_key_exists('timeout', $this->options))
250250
{
251-
$storageOptions = $storage->getOptions();
252-
$this->options['timeout'] = isset($storageOptions['timeout']) ? $storageOptions['timeout'] : 1800;
251+
$this->options['timeout'] = 1800;
253252
}
254253

255254
// read data from storage

0 commit comments

Comments
 (0)