...

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

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

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

View as plain text