0

I have configured Magento to use Redis to store sessions a number of times but currently have an issue where Magento writes session data to the database instead of Redis even though it appears to be configured correctly.

Redis is running and I have double checked the ports are correct / I can connect to it via cli. I am using a new version of Magento so it should natively support this. My Magento configuration is set to use db under the session_save node.

I have taken this from local.xml.additional and understand that the Redis module extends the model that the db session storage mechanism uses, but cannot see why this would not be saving to Redis.

Any ideas?

Indeed the solution is not to forget to activate the Redis session module (Cm_RedisSession.xml) and flush configuration cache.

closed as too broad by Anna Völkl, Amit Bera, Marius, MTM, Fabian Blechschmidt Oct 1 '14 at 22:15

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • I am confused do you want sessions to be saved in redis or the normal database? – David Manners Jul 19 '14 at 8:35
  • If your node says db, then it is saved to db not redis. Sounds like a configuration error to me. – Fabian Blechschmidt Oct 1 '14 at 22:15
5

Change your local.xml to

        <session_save>db</session_save>
        <redis_session>                       <!-- All options seen here are the defaults -->
            <host>127.0.0.1</host>            <!-- Specify an absolute path if using a unix socket -->
            <port>6379</port>
            <password></password>             <!-- Specify if your Redis server requires authentication -->
            <timeout>2.5</timeout>            <!-- This is the Redis connection timeout, not the locking timeout -->
            <persistent></persistent>         <!-- Specify unique string to enable persistent connections. -->
            <db>2</db>                        <!-- Redis database number; protection from accidental loss is improved by using a unique DB number for sessions -->
            <compression_threshold>2048</compression_threshold>  <!-- Set to 0 to disable compression (recommended when suhosin.session.encrypt=on); known bug with strings over 64k: https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/issues/18 -->
            <compression_lib>gzip</compression_lib>              <!-- gzip, lzf or snappy -->
            <log_level>4</log_level>               <!-- 0 (emergency: system is unusable), 4 (warning; additional information, recommended), 5 (notice: normal but significant condition), 6 (info: informational messages), 7 (debug: the most information for development/testing) -->
            <max_concurrency>6</max_concurrency>                 <!-- maximum number of processes that can wait for a lock on one session; for large production clusters, set this to at least 10% of the number of PHP processes -->
            <break_after_frontend>5</break_after_frontend>       <!-- seconds to wait for a session lock in the frontend; not as critical as admin -->
            <break_after_adminhtml>30</break_after_adminhtml>
            <bot_lifetime>7200</bot_lifetime>                    <!-- Bots get shorter session lifetimes. 0 to disable -->
        </redis_session>

under the global node with your redis configs. That should fix your issue. Source here.

=====

Very important: even with updated local.xml, you need to enable Cm_RedisSession (it is disabled by default in all Magento versions up to date (1.9.2.3)). To do that, open ./app/etc/modules/Cm_RedisSession.xml and make sure you have the following configuration:

<config>
  <modules>
    <Cm_RedisSession>
      <active>true</active>
      <codePool>community</codePool>
    </Cm_RedisSession>
  </modules>
</config>

By default, the line says "false".

  • Thank you for the response. This matches my configuration exactly (except the log level which I just changed for elimination). It is still saving sessions to the database. As mentioned I can connect to Redis via cli. I have also been using the original Colin Mollenhour module repo as reference: [link][github.com/colinmollenhour/Cm_RedisSession]. So, the problem persists. Any further suggestions? – James Jul 19 '14 at 11:21
  • I should also mention that is is successfully saving cache data to Redis which leads me to believe that the problem isn't with Redis itself. – James Jul 19 '14 at 11:25
  • Flush all the caches both via admin and manually. Configs are normally cached. – mbalparda Jul 19 '14 at 12:37
  • Yes, all caches cleared (manually and via admin). You gave a text book answer, the only thing I can think of as a cause is an issue with EE 1.14 which is the version in question (it is still saving to DB) – James Jul 19 '14 at 12:39
  • What if you change db for files? – mbalparda Jul 19 '14 at 13:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.