The Session Reminder module for Drupal displays a modal before a user's session is about to expire, allowing them to extend their session duration and prevent logout.

Features

  • Pre-Expiration Notification: A modal window alerts users before their session expires.
  • Session Extension: The modal includes a button that updates the session cookie's expiration time based on the cookie_lifetime value.
  • Customizable Design: Administrators can configure the modal's appearance, including border-radius, background color, button color, and text color.
  • Role-Based Visibility: Administrators can define which user roles see the modal (authenticated users only).
  • Graceful User Experience: The modal is designed to minimize disruption to the user's workflow.

Installation

To install the Session Reminder module:

  • Download the module from the official Drupal repository or using Composer:
    composer require drupal/session_reminder
  • Enable the module via the Extend page (/admin/modules) or by running the following Drush command:
    drush en session_reminder -y
  • Clear the site cache to apply changes:
    drush cr
  • Once enabled, access the configuration page at /admin/config/session-reminder to set up the module.

Configuration

Configure the module at /admin/config/session-reminder or via the admin menu under "Configuration > People > Session Reminder."

Functional Settings:

Session Reminder - Config
  • Warning Threshold: Set how many seconds before session expiration the modal should appear.
  • User Roles: Choose which roles will see the modal notification.

Style:

Session Reminder - Style Config

Take advantage of the live preview feature in the style tab to customize the modal's appearance in real-time. As you make changes, the preview will update instantly, allowing you to see how the modal looks with the selected styles. This makes it easier to refine the design to match your preferences or platform requirements.

The following style options are available for customization:

  • Modal Background Color: Adjust the overall background color of the modal window.
  • Modal Title Color: Change the color of the modal's title text.
  • Modal Text Color: Customize the color of the body text inside the modal.
  • Submit Button Background Color: Set the background color for the submit button.
  • Submit Button Text Color: Define the color of the text displayed on the submit button.

With the live preview, you can experiment freely and achieve the perfect look for your modal in a seamless and efficient way.

The module uses the cookie_lifetime value from Drupal's services.yml file to calculate session duration.

  • cookie_lifetime: Defines the session cookie's validity duration (default: 200,000 seconds, ~56 hours).
  • gc_maxlifetime: Specifies the maximum lifetime of session storage. If set to 0, session data has no expiration, which prevents the modal from functioning correctly.

If gc_maxlifetime is set to 0, a warning will be displayed on the configuration page.

Usage

Once enabled and configured, authenticated users will see the session expiration reminder modal based on the defined warning threshold and roles.

Troubleshooting

  • No Modal Appears: Ensure cookie_lifetime is set correctly and gc_maxlifetime is not set to 0.
  • Check the "Configuration > People > Session Reminder" page for additional information about session settings.

Project information

Releases