Problem/Motivation

The session.storage.options parameter does not always define the cookie_lifetime key. This array comes from the service definition (core + settings.php + environment-specific overrides). If the site does not set cookie_lifetime, the key may simply not exist in the array, and accessing it directly will trigger a warning Warning: Undefined array key "cookie_lifetime" in autologout_page_attachments_alter() (line 256 of modules/contrib/autologout/autologout.module).

Steps to reproduce

1. Upgrade to latest version
2. Log in

Proposed resolution

Check the access to session options to avoid warnings when cookie_lifetime is not defined, using a safe fallback. This eliminates the “Undefined array key” notice without changing the expected behavior when the key is present.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork autologout-3580557

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jonathandealmeida created an issue. See original summary.

jonathandealmeida’s picture

Status: Active » Needs review

I pushed a fix for the undefined array key warning related to cookie_lifetime.

This change adds a fallback when the key is not defined in session.storage.options.

Branch: 3580557-undefined-array-key

deaom’s picture

Version: 8.x-1.x-dev » 2.x-dev

The issue of the lifetime cookie is already addressed in #3580058: Undefined array key "cookie_samesite" warning after upgrade to 2.02. Also in issue summary the first step to reproduce is upgrade to latest version, which is 2.x and then the issue is opened as a 8.x version. Basically needs to be closed as a duplicate, but leaving that to maintainers.

the_g_bomb’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

joshahubbers’s picture

Sorry, but I applied the patch in #3580058: Undefined array key "cookie_samesite" warning after upgrade to 2.02, and it does fix the issue in autologout_user_login(), but not in
autologout_page_attachments_alter().

My bad, I did not apply the patch propery.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.