Issues saving session

99 vistas
Ir al primer mensaje no leído

Lee Sylvester

no leída,
1 oct 2012, 5:07:55 p.m.1/10/2012
para goril...@googlegroups.com
Hey guys,

So, I'm using the Gorilla Session package in my project.  Currently, I'm testing with some dummy values.  However, whenever I save the values, I get the error "securecookie: the value could not be encoded". What reasons would I be getting this? I'm using simple values, so there should be no reason why they wouldn't be encodable. I've tried both with and without authentication and encryption keys, but to no avail.

Any ideas?

Thanks,
Lee

Lee Sylvester

no leída,
1 oct 2012, 5:36:52 p.m.1/10/2012
para goril...@googlegroups.com

Figured it out.  I updated the EncodeMulti function like so:

 

func EncodeMulti(name string, value interface{},

                codecs ...Codec) (string, error) {

                for _, codec := range codecs {

                                if encoded, err := codec.Encode(name, value); err == nil {

                                                return encoded, nil

                                } else {

                                    return "", err  // added this line

                                }

                }

                return "", errors.New("securecookie: the value could not be encoded")

}

 

The nested error output that the encryption string was too long (even though I had the lib generate it for me).  This would be a handy error for many peeps to receive, I’m sure.

 

Cheers,

Lee

Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos