Uploaded image for project: 'Moodle QA'
  1. Moodle QA
  2. MDLQA-12282 Moodle 3.6 QA
  3. MDLQA-12774

CLONE - memcached and redis session handlers can be used to manage users sessions

    XMLWordPrintable

    Details

      Description

      Prerequisites

      1. Memcache server (localhost is fine, otherwise replace 127.0.0.1 below)
      2. Redis server (again localhost if fine)
      3. php-memcached and php-redis extensions
      4. $CFG->autologinguests = 0; (setting disabled)
      5. Two additional language packs installed
      6. Two different browsers

      Setup
      We need to test each of them so we need repeat the steps below after setting each of the session handlers in our config.php:

      • memcached session handler
        1. Log out if you are logged in
        2. Remove any config.php $CFG->session_handler_* stuff you previously added
        3. Paste this in your config.php before require_once...lib/setup.php

              $CFG->session_handler_class = '\core\session\memcached';
              $CFG->session_memcached_save_path = '127.0.0.1:11211';
              $CFG->session_memcached_prefix = 'memc.sess.key.';
              $CFG->session_memcached_acquire_lock_timeout = 120;
              $CFG->session_memcached_lock_expire = 7200;
              

      • redis session handler
        1. Log out if you are logged in
        2. Remove any config.php $CFG->session_handler_* stuff you previously added
        3. Paste this in your config.php before require_once...lib/setup.php

              $CFG->session_handler_class = '\core\session\redis';
              $CFG->session_redis_host = '127.0.0.1';
              $CFG->session_redis_port = 6379;  // Optional.
              $CFG->session_redis_database = 0;  // Optional, default is db 0.
              $CFG->session_redis_prefix = 'qa.sess.'; // Optional, default is don't set one.
              $CFG->session_redis_acquire_lock_timeout = 120;
              $CFG->session_redis_lock_expire = 7200;
          

      Test

      1. Use the CLI to run php admin/cli/purge_caches.php
      2. Set up the session handling according to config-dist.php instructions (you can also check Session_handling moodle docs page)
      3. Log in and switch the language to a non-default one. Browser through some site-level pages (such as calendar, notes, tags) and make sure the manually selected language is still the current one.
      4. Open a session with the same user in another browser, leave the previous browser session opened
      5. Log in. Check that you end up with the default language and switch the language to yet another one.
      6. Return to the previous session and check the language selected here is still the same, unaffected by the language selected in the other session.
      7. Log out from the last opened session
      8. Open another session with a different user and again check you end up with the default language
      9. Log out from all opened sessions
      10. Set http://YOURSITE/admin/index.php url in your browser, you should be redirected to the login page
      11. Log in as admin and check that you are redirected to where you wanted to be -
        admin/index.php

      Notes:

      • To make sure the memcached server is really used, you can do

        $ echo "flush_all" | nc localhost 11211
        

        which should force all users to be logged out.

      • With Redis, the same test can be done via

        $ redis-cli flushall
        

      • The config-dist.php recommends to use igbinary as the serializer for redis store. At the time of writing this (May 2017) there are reported issues with igbinary and php7 so you may want to use the default serializer.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: