session

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearAllSessions

func ClearAllSessions(baseDir string) error

ClearAllSessions removes all session data

func ListAllSessions

func ListAllSessions(baseDir string) ([]string, error)

ListAllSessions returns all session directories

Types

type Cookie struct {
	Name     string    `json:"name"`
	Value    string    `json:"value"`
	Path     string    `json:"path,omitempty"`
	Domain   string    `json:"domain,omitempty"`
	Expires  time.Time `json:"expires,omitempty"`
	MaxAge   int       `json:"maxAge,omitempty"`
	Secure   bool      `json:"secure,omitempty"`
	HttpOnly bool      `json:"httpOnly,omitempty"`
	SameSite string    `json:"sameSite,omitempty"`
}

Cookie represents a serializable cookie

type SessionManager

type SessionManager struct {
	// contains filtered or unexported fields
}

SessionManager manages session persistence (cookies and variables)

func NewSessionManager

func NewSessionManager(baseDir, httpFilePath, sessionName string) (*SessionManager, error)

NewSessionManager creates a new session manager If sessionName is provided, uses named session; otherwise uses directory-based session

func (*SessionManager) ClearAll

func (sm *SessionManager) ClearAll()

ClearAll clears both cookies and variables

func (*SessionManager) ClearCookies

func (sm *SessionManager) ClearCookies()

ClearCookies clears all cookies

func (*SessionManager) ClearVariables

func (sm *SessionManager) ClearVariables()

ClearVariables clears all variables

func (*SessionManager) Delete

func (sm *SessionManager) Delete() error

Delete removes the session directory from disk

func (*SessionManager) GetAllCookies

func (sm *SessionManager) GetAllCookies() map[string][]Cookie

GetAllCookies returns all cookies

func (*SessionManager) GetAllVariables

func (sm *SessionManager) GetAllVariables() map[string]interface{}

GetAllVariables returns all session variables

func (*SessionManager) GetCookiesForURL

func (sm *SessionManager) GetCookiesForURL(urlStr string) []*http.Cookie

GetCookiesForURL returns cookies for a given URL

func (*SessionManager) GetSessionPath

func (sm *SessionManager) GetSessionPath() string

GetSessionPath returns the session path (for display purposes)

func (*SessionManager) GetVariable

func (sm *SessionManager) GetVariable(name string) (interface{}, bool)

GetVariable gets a session variable

func (*SessionManager) GetVariableAsString

func (sm *SessionManager) GetVariableAsString(name string) (string, bool)

GetVariableAsString gets a session variable as string

func (*SessionManager) Load

func (sm *SessionManager) Load() error

Load loads both cookies and variables from disk

func (*SessionManager) LoadCookies

func (sm *SessionManager) LoadCookies() error

LoadCookies loads cookies from disk

func (*SessionManager) LoadVariables

func (sm *SessionManager) LoadVariables() error

LoadVariables loads variables from disk

func (*SessionManager) Save

func (sm *SessionManager) Save() error

Save saves both cookies and variables to disk

func (*SessionManager) SaveCookies

func (sm *SessionManager) SaveCookies() error

SaveCookies saves cookies to disk

func (*SessionManager) SaveVariables

func (sm *SessionManager) SaveVariables() error

SaveVariables saves variables to disk

func (*SessionManager) SetCookiesFromResponse

func (sm *SessionManager) SetCookiesFromResponse(urlStr string, cookies []*http.Cookie)

SetCookiesFromResponse stores cookies from an HTTP response

func (*SessionManager) SetVariable

func (sm *SessionManager) SetVariable(name string, value interface{})

SetVariable sets a session variable

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL