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

MaxAge checks against wrong value in Save func #96

Closed
mziraki opened this issue Sep 22, 2016 · 5 comments
Closed

MaxAge checks against wrong value in Save func #96

mziraki opened this issue Sep 22, 2016 · 5 comments

Comments

@mziraki
Copy link

mziraki commented Sep 22, 2016

@pappz @elithrar
in file store.go, line 216:

func (s *FilesystemStore) Save(r *http.Request, w http.ResponseWriter,
    session *Session) error {
    // Delete if max-age is <= 0
    if session.Options.MaxAge <= 0 { \\ this line
        if err := s.erase(session); err != nil {
            return err
        }
        http.SetCookie(w, NewCookie(session.Name(), "", session.Options))
        return nil
    }
...

must be "session.Options.MaxAge < 0" because 0 value means browser expires cookie when you close the browser, but when it is "session.Options.MaxAge <= 0". it removes session file right away and when you want to "Save" session with MaxAge 0 for "until browser is open expiration time", Save function tries to delete file that not exists yet and os.Remove() in erase function returns "remove path\to\tempdir\session_: The system cannot find the file specified." PathError.

@pappz
Copy link
Contributor

pappz commented Sep 28, 2016

You are probably right. I will working with session handling in the next couple of week and I will check it.

@lfkeitel
Copy link

As you could probably tell from my misplaced issue, I'm experiencing the same thing. I was using a MaxAge of 0 and after updating the package my application didn't work. I've made a temporary fix in my copy but this could easily trip up others as well.

adborden added a commit to cloud-gov/cg-dashboard that referenced this issue Jan 13, 2017
gorilla Session creation isn't handled correctly when MaxAge is unset. Work
around upstream bug[1] by explicitly setting MaxAge.

[1] gorilla/sessions#96
jmcarp added a commit to jmcarp/sessions that referenced this issue Jan 14, 2017
@jimd33463
Copy link

I came across the same issue. So, if this hasn't yet been addressed in a subsequent release, how do I go about updating the code for my project? (new to GitHub)

@kisielk
Copy link
Contributor

kisielk commented May 18, 2017

See #103

@elithrar
Copy link
Contributor

Closing; tracking in #103

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.

6 participants