Esempio n. 1
0
// CreateSession 创建Session
func (this *MemSessionContainer) CreateSession() (Session, bool) {
	if this.closed {
		return nil, false
	}
	this.rwm.Lock()
	defer this.rwm.Unlock()
	var sessionId = util.NewUUID().Hex()
	var ss = newMemSession(sessionId)
	ss.SetDeadline(this.defaultExpire)
	this.sessionCounter++
	this.sessions[sessionId] = ss
	return ss, true
}
Esempio n. 2
0
// Token 生成一个CSRF认证字符串
func (this *TemplateCSRF) Token() template.HTML {
	var token = util.NewUUID().Hex()
	this.sess.SetInt(token, int(time.Now().Unix())) //记录生成时间(秒)
	return template.HTML(token)
}