3

Currently, my sessions table is 1.6gb with 3,956,161 total rows. I think the sessions does not expired. I have a default settings in my settings.php as follows:

ini_set('arg_separator.output',     '&');
ini_set('magic_quotes_runtime',     0);
ini_set('magic_quotes_sybase',      0);
ini_set('session.cache_expire',     200000);
ini_set('session.cache_limiter',    'none');
ini_set('session.cookie_lifetime',  2000000);
ini_set('session.gc_maxlifetime',   200000);
ini_set('session.save_handler',     'user');
ini_set('session.use_only_cookies', 1);
ini_set('session.use_trans_sid',    0);
ini_set('url_rewriter.tags',        '');

is the variable above related to sessions table? If yes, what is the recommended settings to expire the session after 2 days?

Update:

I just found that this is due to OS limitation of ubuntu which I am currently using. This was explain at this drupal module: https://drupal.org/project/session_expire

The problem is, Session Expire module is still in alpha release.

Is there any other module that can do this same?

  • Nope, variables above are not related to session table directly. Also, asking for resources is not a good thing to do, see help center. If you would ask something more practical, like "how to prevent session table growth" or "how to make sessions expire", it would be more useful for future. Last but not least, ever considered moving sessions out of DB? – Mołot Jan 21 '14 at 8:41
  • 1
    You are wrong. They are related. I'm glad i've found the answer. – jaypabs Jan 21 '14 at 9:43
  • 1
    I wrote they are not related directly. Of course if you found your answer, you are most welcome to post it. – Mołot Jan 21 '14 at 9:44
4

While waiting for an answer, I found the solution at this blog.

All you need to do is to edit the settings.php under /sites/default folder.

Here are the two variables that need to be set:

ini_set('session.gc_probability', 1); 
ini_set('session.gc_divisor', 100);

Be sure to change also the cache expiry of the following variable according to your needs:

ini_set('session.cache_expire',     3600);
ini_set('session.cookie_lifetime',  3600);
ini_set('session.gc_maxlifetime',   3600);

The default is 200000. 3600 is equavalent to 1 hour.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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