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.
My business uses D7 for the company page, and on numerous occasions when navigating between pages, the user session is terminated, and the session cookies are also deleted. We have to re-login on each occasion. It happens numerous times a day and the log does not indicate anything.
Problem similar to: https://www.drupal.org/node/641140
Comments
Comment #2
cilefen CreditAttribution: cilefen commentedPlease add to the issue summary a description of your hosting environment. I am unclear about what you mean by session cookies being deleted—cookies themselves are stored in client browsers. Are they all being deleted? What is happening in Drupal's session table?
Comment #3
tesmondh CreditAttribution: tesmondh commentedRunning CentOS 6 with a LAMP environment. After a period of time after logging in, I will navigate to another page and the session is terminated. So yes, the cookies in the client browser is be deleted. The log is as below:
user 11/19/2016 - 6:44pm Session opened for tesmondh. Tesmond H
user 11/19/2016 - 6:44pm Session closed for tesmondh. Tesmond H
user 11/19/2016 - 6:44pm Session opened for tesmondh. Tesmond H
user 11/19/2016 - 6:44pm Session closed for tesmondh. Tesmond H
user 11/19/2016 - 6:33pm Session opened for tesmondh. Tesmond H
user 11/19/2016 - 6:25pm Session opened for tesmondh. Tesmond H
user 11/19/2016 - 6:02pm Session opened for tesmondh. Tesmond H
user 11/19/2016 - 6:01pm Session closed for tesmondh. Tesmond H
At no point in time did I ever click the "logout" button.
Comment #4
mark_fullmerWhat are the PHP values in your settings.php file for session.gc_maxlifetime and session.cookie_lifetime? The default settings that ship with Drupal are below. Also check the server settings (e.g., phpinfo() or /admin/reports/status/php). Low (or nonexistent) settings for this could trigger the server session expiration.
Comment #5
cilefen CreditAttribution: cilefen commentedAdding to #4, did the problem begin with at a particular point in time where there was a software or a configuration change?
Comment #6
parthpandya24 CreditAttribution: parthpandya24 commentedWhich version of Drupal you are using?
If older one then update latest D7 core.
Comment #7
tesmondh CreditAttribution: tesmondh commentedI am running the latest version of Drupal 7 (7.52). The session lifetime for both values are 200000.
We tend to notice the issue after access non-drupal pages on our site that use PHP's stream_context_create to send headers to a specific non-Drupal page to tell us whether or not the user is currently logged in, and if they are; what roles do they have. That page incorporates this code:
define('DRUPAL_ROOT', getcwd());
include_once('./includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $user;
The weird thing is it hasn't done it in the last several days, it's just sometimes. Not sure why.
Comment #8
amit0212 CreditAttribution: amit0212 as a volunteer and commentedYou should check weather the settings.php file in drupal have the write permission, then only the changes will affect in your code.
After that, change this in settings.php.
replace ini_set('session.cookie_lifetime', 2000000);
with ini_set('session.cookie_lifetime', 0);