gf/net/ghttp/ghttp_server_config_session.go

39 lines
1.0 KiB
Go
Raw Normal View History

// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
2018-09-14 13:02:13 +08:00
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
2018-09-14 13:02:13 +08:00
package ghttp
import (
"time"
"github.com/gogf/gf/os/gsession"
)
2018-09-14 13:02:13 +08:00
2020-05-01 03:31:04 +08:00
// SetSessionMaxAge sets the SessionMaxAge for server.
func (s *Server) SetSessionMaxAge(ttl time.Duration) {
s.config.SessionMaxAge = ttl
2018-09-14 13:02:13 +08:00
}
2020-05-01 03:31:04 +08:00
// SetSessionIdName sets the SessionIdName for server.
2018-09-14 13:02:13 +08:00
func (s *Server) SetSessionIdName(name string) {
2019-06-19 09:06:52 +08:00
s.config.SessionIdName = name
2018-09-14 13:02:13 +08:00
}
2020-05-01 03:31:04 +08:00
// SetSessionStorage sets the SessionStorage for server.
func (s *Server) SetSessionStorage(storage gsession.Storage) {
s.config.SessionStorage = storage
}
2020-05-01 03:31:04 +08:00
// GetSessionMaxAge returns the SessionMaxAge of server.
func (s *Server) GetSessionMaxAge() time.Duration {
2019-06-19 09:06:52 +08:00
return s.config.SessionMaxAge
2018-09-14 13:02:13 +08:00
}
2020-05-01 03:31:04 +08:00
// GetSessionIdName returns the SessionIdName of server.
2018-09-14 13:02:13 +08:00
func (s *Server) GetSessionIdName() string {
2019-06-19 09:06:52 +08:00
return s.config.SessionIdName
2018-09-14 13:02:13 +08:00
}