Bug #5877

Replace homemade ChamiloSession and $_SESSION calls with the Silex\Provider\SessionServiceProvider

Added by Julio Montoya over 8 years ago. Updated almost 8 years ago.

Feature implemented
Target version:
Start date:
Due date:
% Done:


Estimated time:
SCRUM pts - complexity:


This will help a lot when running phpunit tests.

I've been testing and I have found some warnings due the session

/var/www/chamilo11$ phpunit -c tests/phpunit --filter testIs_username_available
PHPUnit 3.7.12 by Sebastian Bergmann.
Configuration read from /var/www/chamilo11/tests/phpunit/phpunit.xml


Time: 12 seconds, Memory: 17.25Mb

There was 1 error:

1) UserManagerTest::testIs_username_available
session_start(): Cannot send session cookie - headers already sent by (output started at /usr/share/php/PHPUnit/Util/Printer.php:172)


Tests: 2, Assertions: 1, Errors: 1.

With the that service provider we could simulate session values

Yeah I know it will be a lot of work ...

Related issues

Related to Chamilo LMS - Feature #4378: improve session destroy removing PHPSESSID from browserNeeds more info13/02/2012

Related to Chamilo LMS - Feature #6711: Roles in ChamiloNew18/09/2013


Associated revisions

Revision b324cb06 (diff)
Added by Julio Montoya about 8 years ago

Replacing the ChamiloSession with the SessionServiceProvider see #5877



Updated by Julio Montoya over 8 years ago

  • Description updated (diff)

Updated by Julio Montoya over 8 years ago

  • Category set to System
  • Complexity changed from Normal to Difficult
  • SCRUM pts - complexity changed from ? to 40

Updated by Julio Montoya about 8 years ago

  • Status changed from New to Needs testing
  • Priority changed from Low to Normal
  • Target version set to 2.0
  • % Done changed from 0 to 50

We're using right now 2 session "handlers" the ChamiloSession using calls like Session::get('session_value') and $_SESSION['session_value'];

Now, ChamiloSession is using the $app['session'] which is the same thing like before, but we can use all the benefits of the $app['session'] parameters like setting the session params like this example and using the security roles. An array of options that is passed to the constructor of the service.

In case of the default NativeSessionStorage, the most useful options are:

name: The cookie name (_SESS by default)
id: The session id (null by default)
cookie_lifetime: Cookie lifetime
cookie_path: Cookie path
cookie_domain: Cookie domain
cookie_secure: Cookie secure (HTTPS)
cookie_httponly: Whether the cookie is http only
However, all of these are optional. Sessions last as long as the browser is open. To override this, set the lifetime option.

For a full list of available options, read the PHP official documentation.

session.test: Whether to simulate sessions or not (useful when writing functional tests).

Updated by Julio Montoya almost 8 years ago

  • Status changed from Needs testing to Feature implemented

Also available in: Atom PDF