Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 [Feature]: missing session SessionOnly (cookie) #2145

Closed
3 tasks done
pjebs opened this issue Oct 8, 2022 · 6 comments · Fixed by #2152
Closed
3 tasks done

🚀 [Feature]: missing session SessionOnly (cookie) #2145

pjebs opened this issue Oct 8, 2022 · 6 comments · Fixed by #2152

Comments

@pjebs
Copy link
Contributor

pjebs commented Oct 8, 2022

Feature Description

See: https://pkg.go.dev/github.com/gofiber/fiber/[email protected]/middleware/session#Config

There seems to be no option to set SessionOnly.

See: https://pkg.go.dev/github.com/gofiber/fiber/v2#Cookie

SessionOnly deletes the cookies when the user closes the browser window.

If you set Expiration to 0, it deletes it immediately.

There is also ambiguity: Does Expiration refer to how long the data is stored in the session data or how long the cookie lasts for?

Additional Context (optional)

No response

Code Snippet (optional)

No response

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have checked for existing issues that describe my suggestion prior to opening this one.
  • I understand that improperly formatted feature requests may be closed without explanation.
@pjebs pjebs changed the title 🚀 [Feature]: session SessionOnly 🚀 [Feature]: missing session SessionOnly (cookie) Oct 8, 2022
@li-jin-gou
Copy link
Contributor

li-jin-gou commented Oct 9, 2022

Refer to https://stackoverflow.com/questions/14196671/session-only-cookies-with-javascript and It should be a front-end FEATURE.

@pjebs
Copy link
Contributor Author

pjebs commented Oct 9, 2022

No, it can be done via backend.
You have to omit expiry value. Problem is you can't omit because a value of 0 ( the "zero value") means something else i.e. Delete session immediately.

@li-jin-gou
Copy link
Contributor

image
It also seems to be fine without setting.

@pjebs
Copy link
Contributor Author

pjebs commented Oct 9, 2022

You can't unset it. A value of zero is not the same

@yvestumushimire
Copy link
Contributor

Hello can I jump in and help?

@efectn
Copy link
Member

efectn commented Oct 12, 2022

Hello can I jump in and help?

Sure. You can create a PR

yvestumushimire added a commit to yvestumushimire/fiber that referenced this issue Oct 13, 2022
yvestumushimire added a commit to yvestumushimire/fiber that referenced this issue Oct 20, 2022
yvestumushimire added a commit to yvestumushimire/fiber that referenced this issue Nov 14, 2022
ReneWerner87 pushed a commit that referenced this issue Mar 12, 2023
* feature: session only for zero expire cookie #2145

* refactor condition to set MaxAge and Expire on cookie

* move checking zero maxage and expire in session middleware

Signed-off-by: Yves Tumushimire <[email protected]>

* feature: session only for zero expire cookie #2145

* refactor condition to set MaxAge and Expire on cookie

* move checking zero maxage and expire in session middleware

Signed-off-by: Yves Tumushimire <[email protected]>

* CR changes

* some updates

---------

Signed-off-by: Yves Tumushimire <[email protected]>
Co-authored-by: Muhammed Efe Çetin <[email protected]>
Co-authored-by: René Werner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants