Skip to content

Reverting Session() returning nil if session does not exist (issue #287)#289

Merged
appleboy merged 1 commit intogin-contrib:masterfrom
rogersm:revert-issue-287
May 22, 2025
Merged

Reverting Session() returning nil if session does not exist (issue #287)#289
appleboy merged 1 commit intogin-contrib:masterfrom
rogersm:revert-issue-287

Conversation

@rogersm
Copy link
Copy Markdown
Contributor

@rogersm rogersm commented Apr 16, 2025

As reported by @alan-anzenna this reverts Issue #287.

Description:

s.store.Get() returns a new session when returning an error for gorilla session's CookieStore.

// Get returns a session for the given name after adding it to the registry.
//
// It returns a new session if the sessions doesn't exist. Access IsNew on
// the session to check if it is an existing session or a new one.
//
// It returns a new session and an error if the session exists but could
// not be decoded.

In 1.0.2, Session() would use this new session. In 1.0.3, Session() returns nil.

This behavior was changed here.

Most of the callers in sessions.go (such as ID()) are not written to handle Session() returning nil.

@wzxjohn
Copy link
Copy Markdown

wzxjohn commented Apr 17, 2025

I think 1.0.3 should be retract in go.mod.

@sunshineplan
Copy link
Copy Markdown

@appleboy When you have a moment, could you please take a look at this issue? Thanks!

@psimoesSsimoes
Copy link
Copy Markdown

@appleboy , When you get a chance, would you mind looking into this issue? TKs!

@appleboy appleboy added the bug label May 22, 2025
@appleboy
Copy link
Copy Markdown
Member

https://github.com/gin-contrib/sessions/releases/tag/v1.0.4

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants