github.com/wangyougui/gf/v2@v2.6.5/net/ghttp/ghttp_server_config_session.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/wangyougui/gf. 6 7 package ghttp 8 9 import ( 10 "time" 11 12 "github.com/wangyougui/gf/v2/os/gsession" 13 ) 14 15 // SetSessionMaxAge sets the SessionMaxAge for server. 16 func (s *Server) SetSessionMaxAge(ttl time.Duration) { 17 s.config.SessionMaxAge = ttl 18 } 19 20 // SetSessionIdName sets the SessionIdName for server. 21 func (s *Server) SetSessionIdName(name string) { 22 s.config.SessionIdName = name 23 } 24 25 // SetSessionStorage sets the SessionStorage for server. 26 func (s *Server) SetSessionStorage(storage gsession.Storage) { 27 s.config.SessionStorage = storage 28 } 29 30 // SetSessionCookieOutput sets the SetSessionCookieOutput for server. 31 func (s *Server) SetSessionCookieOutput(enabled bool) { 32 s.config.SessionCookieOutput = enabled 33 } 34 35 // SetSessionCookieMaxAge sets the SessionCookieMaxAge for server. 36 func (s *Server) SetSessionCookieMaxAge(maxAge time.Duration) { 37 s.config.SessionCookieMaxAge = maxAge 38 } 39 40 // GetSessionMaxAge returns the SessionMaxAge of server. 41 func (s *Server) GetSessionMaxAge() time.Duration { 42 return s.config.SessionMaxAge 43 } 44 45 // GetSessionIdName returns the SessionIdName of server. 46 func (s *Server) GetSessionIdName() string { 47 return s.config.SessionIdName 48 } 49 50 // GetSessionCookieMaxAge returns the SessionCookieMaxAge of server. 51 func (s *Server) GetSessionCookieMaxAge() time.Duration { 52 return s.config.SessionCookieMaxAge 53 }