Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix for Warning: ini_set(): A session is active... #229

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/config/sfFactoryConfigHandler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public function execute($configFiles)
unset($parameters['database']);
}

if (isset($config['user']['param']['timeout'])) {
$defaultParameters[] = sprintf("'gc_maxlifetime' => %d,", $config['user']['param']['timeout']);
}

$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));
break;

Expand Down
7 changes: 7 additions & 0 deletions lib/storage/sfSessionStorage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function initialize($options = null)
'session_cookie_secure' => $cookieDefaults['secure'],
'session_cookie_httponly' => isset($cookieDefaults['httponly']) ? $cookieDefaults['httponly'] : false,
'session_cache_limiter' => null,
'gc_maxlifetime' => 1800,
), $options);

// initialize parent
Expand Down Expand Up @@ -90,6 +91,12 @@ public function initialize($options = null)
session_cache_limiter($this->options['session_cache_limiter']);
}

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

if ($this->options['auto_start'] && !self::$sessionStarted)
{
session_start();
Expand Down
10 changes: 2 additions & 8 deletions lib/user/sfBasicSecurityUser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
* (c) 2004-2006 Sean Kerr <sean@code-box.org>
*
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Expand Down Expand Up @@ -42,7 +42,7 @@ public function clearCredentials()

/**
* Returns the current user's credentials.
*
*
* @return array
*/
public function getCredentials()
Expand Down Expand Up @@ -251,12 +251,6 @@ public function initialize(sfEventDispatcher $dispatcher, sfStorage $storage, $o
$this->options['timeout'] = 1800;
}

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

// read data from storage
$this->authenticated = $storage->read(self::AUTH_NAMESPACE);
$this->credentials = $storage->read(self::CREDENTIAL_NAMESPACE);
Expand Down