diff options
-rw-r--r-- | doc.go | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -48,6 +48,9 @@ And finally we call session.Save() to save the session in the response. Note that in production code, we should check for errors when calling session.Save(r, w), and either display an error message or otherwise handle it. +Save must be called before writing to the response, otherwise the session +cookie will not be sent to the client. + Important Note: If you aren't using gorilla/mux, you need to wrap your handlers with context.ClearHandler as or else you will leak memory! An easy way to do this is to wrap the top-level mux when calling http.ListenAndServe: @@ -56,9 +59,6 @@ is to wrap the top-level mux when calling http.ListenAndServe: The ClearHandler function is provided by the gorilla/context package. -Also: Call Save before writing to the response, otherwise the session -cookie will not be sent to the client. - That's all you need to know for the basic usage. Let's take a look at other options, starting with flash messages. |