Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello there,
I wanna using phpredis to storing our site session, so I modified on php.ini then add:
session.save_handler = redis
session.save_path = "tcp://localhost:6379"
And I tested on our phpinfo() the information are ok:
I create a custom module, and on hook_init(), I create a Session:
session_start();
if (isset($_SESSION['country']))
{
$_SESSION['country'] = $country_code;
}
The session $_SESSION['country'] is storing successfully, but it not storing by redis, I tried search on redis server but I was not found anything stuff.
Everyone has experience?
Comment | File | Size | Author |
---|---|---|---|
screen.png | 30.2 KB | johntang |
Comments
Comment #1
pounardThis is because Drupal will override your session handler and use its own, it goes straight to the database. I'd recomend that you try using this module: https://drupal.org/project/session_proxy
Or alternatively you could write a session.inc replacement using Redis, which I didn't because when needed I chose to use the session proxy module instead (which is actually working on a few sites).
Please re-open if you have any other questions or mark it as fixed if this answer suits you.
Comment #2
johntang CreditAttribution: johntang commented@pounard,
I didn't install this module, still keep using Drupal overwrite session but I think this is a best choice for my issue. I will install it on the next coming days and post again.
Thanks for help.
Comment #3
johntang CreditAttribution: johntang commentedOnce I installed https://drupal.org/project/session_proxy module, and config with phpredis, anything ok But I got the message:
and lost all user profile picture on database, I tried increasing the memory to 256MB but still got it.
On our redis server, we saw the memory used is about 30.5 MB. Whenever I disable this module and comment all config stuff on setting.php, it working again.
Whose meets this problem?
Comment #4
pounardThere is great chances that your PHP memory limit exhaustion is due to the site as a whole, if you use a lot of modules etc... Adding a module may have triggered this. But if this is a bug due to the session proxy module, I need to find it, please give me the module versions you are using for all of core, redis and session_proxy.
Comment #5
johntang CreditAttribution: johntang commentedSession proxy: 7.x-1.0-alpha1
Redis: 7.x-2.6
All are latest version.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedHi,
I am reopening this (but changing it to a feature request) because in experimenting with Session Proxy to store sessions in Redis I discovered that it breaks quite a few other modules that depend on the structure of the Drupal sessions table, as I also described at this issue at Session Proxy: https://www.drupal.org/node/1260634#comment-9941293
For instance, the NodeJS module has a function as follows that is expecting to have the uid & sid or ssid present in the session storge:
With Session Proxy currently, it doesn't have that information. It is using the default cache bin structure (
drupal_get_schema_unprocessed('system', 'cache')
). Probably a lot of other modules will cease to work with the current Session Proxy method, such as Session Expire & Session Limit.So, to sum up, having a Redis-module session.inc that could store sessions in Redis with the same structure Drupal uses in the sessions table would perhaps save conflicts with a lot of other modules, or at least make it easier for them to be patched to work.
Comment #7
pounardAre you aware that I'm the maintainer of the two modules ? :) I'm going to give you the exact same answer as in the other module in #1260634: Add ability to manage session storage in APC or memcached:
I'm closing this issue in flavor of the other module, I'd gladly answer any question or take a few minutes to think about solutions for your needs, but you'll have to open a specific issue for each specific need. We'll then see in the other issue queue (Session Proxy one) if the problem is storage specific (for example Redis or Memcache) or if it can be solved more generically in the Session Proxy module.
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedThank you for your reply. That makes sense.