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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃摑 [Feature] [v2]: Add a function to get the session expiry #2989

Closed
3 tasks done
amirrezaDev1378 opened this issue Apr 27, 2024 · 5 comments
Closed
3 tasks done

Comments

@amirrezaDev1378
Copy link

Feature Proposal Description

Currently, there is no clean and performant way to get session expiry, since there is a SetExpiry function it makes sense to have a function that returns the session expiry.

It can be done using something like this :

// middleware/session/session.go

// GetExpiry gets the expiration of this session
func (s *Session) GetExpiry() time.Duration {
	return s.exp
}

,

Alignment with Express API

This is something similar to :

req.session.cookie.expires  

HTTP RFC Standards Compliance

Confirmed.

API Stability

Hence we are only returning the exp variable which is already declared this feature will not have any stability issue.

Feature Examples

store, err := Seesion.Get(c)
	if err != nil {
		return err
	}
	exp := store.GetExpiry()

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have searched for existing issues that describe my proposal before opening this one.
  • I understand that a proposal that does not meet these guidelines may be closed without explanation.
Copy link

welcome bot commented Apr 27, 2024

Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@sixcolors
Copy link
Member

@amirrezaDev1378, we are planning a rewrite of the session for v3. No changes will be made to v2 as it is in maintenance-only mode at this point.

@amirrezaDev1378
Copy link
Author

amirrezaDev1378 commented Apr 27, 2024

@sixcolors Oh, I didn't know that....
I will close the issue.

@gaby
Copy link
Member

gaby commented Apr 27, 2024

@sixcolors Should we keep this open and move it to v3?

@sixcolors
Copy link
Member

sixcolors commented Apr 28, 2024

@sixcolors Should we keep this open and move it to v3?

Ref #2741, my plan is to replace the expires mechanism with an idle timeout approach, as it aligns better with the actual behavior of middleware. The plan for a hard expiry is to leave this as an implementation detail for the user which could be accomplished via a key from the session store. However, it would still be a good idea to allow for access to the idle timeout, probably without extending the session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants