at last in the handlerfunc you can use it like this
Finally in the handlerfunc you can use it like this
func login(w http.ResponseWriter, r *http.Request) {
sess := globalSessions.SessionStart(w, r)
...
...
@@ -70,19 +70,21 @@ at last in the handlerfunc you can use it like this
fmt.Println("password:", r.Form["password"])
}
}
##How to write own provider
When we develop a web app, maybe you want to write a provider because you must meet the requirements.
## How to write own provider?
When you develop a web app, maybe you want to write own provider because you must meet the requirements.
Write a provider is so easy. You only define two struct type(Session and Provider),which satisfy the interface definition.Maybe The memory provider is a good example for you.
Writing a provider is easy. You only need to define two struct types
(Session and Provider), which satisfy the interface definition.
Maybe you will find the **memory** provider as good example.
type SessionStore interface {
Set(key, value interface{}) error //set session value
Get(key interface{}) interface{} //get session value
Delete(key interface{}) error //delete session value
SessionID() string //back current sessionID
Set(key, value interface{}) error //set session value
Get(key interface{}) interface{} //get session value
Delete(key interface{}) error //delete session value
SessionID() string // return current sessionID
SessionRelease() // release the resource
}
...
...
@@ -93,6 +95,7 @@ Write a provider is so easy. You only define two struct type(Session and Provide