func (s *Service) GetUserSession(r *http.Request) (*user.Session, error) {
	signedSessionID, err := s.transport.FetchSessionIDFromRequest(r)
	if err != nil {
		if err == transport.ErrNoSessionOnRequest {
			return nil, nil
		}
		return nil, err
	}
	sessionID, err := s.auth.VerifyAndDecode(signedSessionID)
	if err != nil {
		if err == auth.ErrInvalidSession {
			return nil, nil
		}
		return nil, err
	}
	return s.store.FetchValidUserSession(sessionID)
}
GetUserSession returns a user session from a request. This method only returns valid sessions. Therefore, \
sessions that have expired, or that fail signature verification will return a nil pointer to a user.Session
package sessions
import (
	"net/http"
	"time"
	"github.com/adam-hanna/sessions/auth"
	"github.com/adam-hanna/sessions/store"
	"github.com/adam-hanna/sessions/transport"
	"github.com/adam-hanna/sessions/user"
)
const (
	DefaultExpirationDuration = 3 * 24 * time.Hour  
)
type Service struct {
	store     store.ServiceInterface
	auth      auth.ServiceInterface
	transport transport.ServiceInterface
	options   Options
}
type Options struct {
	ExpirationDuration time.Duration
}
func New(store store.ServiceInterface, auth auth.ServiceInterface, transport transport.ServiceInterface, options Options) *Service {
	setDefaultOptions(&options)
	return &Service{
		store:     store,
		auth:      auth,
		transport: transport,
		options:   options,
	}
}
func (s *Service) IssueUserSession(userID string, json string, w http.ResponseWriter) (*user.Session, error) {
	userSession := user.New(userID, json, s.options.ExpirationDuration)
	signedSessionID, err := s.auth.SignAndBase64Encode(userSession.ID)
	if err != nil {
		return nil, err
	}
	if err = s.store.SaveUserSession(userSession); err != nil {
		return nil, err
	}
	return userSession, s.transport.SetSessionOnResponse(signedSessionID, userSession, w)
}
func (s *Service) ClearUserSession(userSession *user.Session, w http.ResponseWriter) error {
	if err := s.store.DeleteUserSession(userSession.ID); err != nil {
		return err
	}
	return s.transport.DeleteSessionFromResponse(w)
}