Пример #1
0
// Get get session, return sid and value.
func (t *TSession) Get(w http.ResponseWriter, r *http.Request) (id []byte, val interface{}) {
	vcoockie, e := r.Cookie(SID)
	if e != nil {
		return
	}
	sessionData, b := t.Stor.Get(vcoockie.Value).(*tdata)
	// if session deleted or not chek ipProtect then del cookie
	if !b || sessionData == nil || (t.ipProtect && sessionData.ip != strings.SplitN(r.RemoteAddr, ":", 2)[0]) {
		cookie.DelCookie(w, SID)
		return
	}
	return []byte(vcoockie.Value), sessionData.data
}
Пример #2
0
// Del delete session.
func (t *TSession) Del(w http.ResponseWriter, r *http.Request) {
	vcoockie, e := r.Cookie(SID)
	err.Panic(e)
	t.Stor.Del(vcoockie.Value)
	cookie.DelCookie(w, SID)
}
Пример #3
0
// DelCookie del cookie
func (t *TBoxCookie) DelCookie(w http.ResponseWriter, name string) {
	cookie.DelCookie(w, name)
}