Problem/Motivation

I need the cookie (default as cookiesjr) become session cookie. So i set the Expiration to 0.

Steps to reproduce

  1. Set in the configuration of COOKiES module the field Expiration to 0.
  2. Download and install Firefox plugin "Cookie Quick Manager" so to inspect cookies.
  3. After visiting the website and press DENY ALL button in cookies banner, a cookie is created but with expiration date one month(??) later. I send a relative screenshot.

screenshot about expiration

Proposed resolution

Based on Set-Cookie documentation https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie about the Expire option, I copy paste from there

If unspecified, the cookie becomes a session cookie. A session finishes when the client shuts down, after which the session cookie is removed.

So maybe a solution would be if the Expiration field was 0 to not include this option at all?

CommentFileSizeAuthor
Screenshot 2023-02-23 at 12.07.25 PM.jpg87.42 KBperarg

Issue fork cookies-3343952

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

perarg created an issue. See original summary.

anybody’s picture

Version: 1.2.2 » 1.2.x-dev
Assigned: Unassigned » grevil

Thanks for the report. I'd also expect "0" (session duration) to work. We should add a test for that.

@Grevil will have a look and if there are any questions, contact me.
In the meantime, anyone may provide a MR or details to speed things up.

grevil’s picture

Wow, that is really weird...

It even says in the description, "Set to 0 to expire with browser close."
Seems this feature broke at some point, and we simply had no test for this...

But yes, I can reproduce this issue.

grevil’s picture

Priority: Normal » Major
anybody’s picture

Status: Active » Needs work

Probably this is the wrong line: https://git.drupalcode.org/issue/cookies-3343952/-/blob/3343952-expirati...

Guess the empty check is incorrect.

An cookie expiration of 0 (session duration) should be fine. But please test carefully.

anybody’s picture

grevil’s picture

Assigned: grevil » anybody
Status: Needs work » Needs review

Fixed! Works perfectly fine now!

Please review!

anybody’s picture

Assigned: anybody » Unassigned
Status: Needs review » Reviewed & tested by the community

Great work!! :)

anybody’s picture

Status: Reviewed & tested by the community » Fixed

  • Anybody committed badebcce on 1.2.x authored by Grevil
    Issue #3343952 by Grevil, Anybody: Expiration to 0 doesn't create...

Status: Fixed » Closed (fixed)

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