MCPcopy Index your code
hub / github.com/writefreely/writefreely / saveUserSession

Function saveUserSession

session.go:112–135  ·  view source on GitHub ↗
(app *App, r *http.Request, w http.ResponseWriter)

Source from the content-addressed store, hash-verified

110}
111
112func saveUserSession(app *App, r *http.Request, w http.ResponseWriter) error {
113 session, err := app.sessionStore.Get(r, cookieName)
114 if err != nil {
115 return ErrInternalCookieSession
116 }
117
118 // Extend the session
119 session.Options.MaxAge = int(sessionLength)
120
121 // Remove any information that accidentally got added
122 // FIXME: find where Plan information is getting saved to cookie.
123 val := session.Values[cookieUserVal]
124 var u = &User{}
125 var ok bool
126 if u, ok = val.(*User); ok {
127 session.Values[cookieUserVal] = u.Cookie()
128 }
129
130 err = session.Save(r, w)
131 if err != nil {
132 log.Error("Couldn't saveUserSession: %v", err)
133 }
134 return err
135}
136
137func getFullUserSession(app *App, r *http.Request) (*User, error) {
138 u := getUserSession(app, r)

Callers 2

getSessionFlashesFunction · 0.85
addSessionFlashFunction · 0.85

Calls 1

CookieMethod · 0.80

Tested by

no test coverage detected