...

Source file src/github.com/gin-gonic/contrib/sessions/cookie.go

Documentation: github.com/gin-gonic/contrib/sessions

     1  package sessions
     2  
     3  import (
     4  	"github.com/gorilla/sessions"
     5  )
     6  
     7  type CookieStore interface {
     8  	Store
     9  }
    10  
    11  // Keys are defined in pairs to allow key rotation, but the common case is to set a single
    12  // authentication key and optionally an encryption key.
    13  //
    14  // The first key in a pair is used for authentication and the second for encryption. The
    15  // encryption key can be set to nil or omitted in the last pair, but the authentication key
    16  // is required in all pairs.
    17  //
    18  // It is recommended to use an authentication key with 32 or 64 bytes. The encryption key,
    19  // if set, must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256 modes.
    20  func NewCookieStore(keyPairs ...[]byte) CookieStore {
    21  	return &cookieStore{sessions.NewCookieStore(keyPairs...)}
    22  }
    23  
    24  type cookieStore struct {
    25  	*sessions.CookieStore
    26  }
    27  
    28  func (c *cookieStore) Options(options Options) {
    29  	c.CookieStore.Options = &sessions.Options{
    30  		Path:     options.Path,
    31  		Domain:   options.Domain,
    32  		MaxAge:   options.MaxAge,
    33  		Secure:   options.Secure,
    34  		HttpOnly: options.HttpOnly,
    35  	}
    36  }
    37  

View as plain text