Skip to content

Commit

Permalink
slight rewording
Browse files Browse the repository at this point in the history
  • Loading branch information
syntaqx committed Jul 1, 2024
1 parent e5bddd0 commit 06faf43
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,23 @@ cookie.DefaultOptions = &cookie.Options{
}
```

Which will sign all cookies by default, even when using the `Set` and `Get`
methods.

If you have any unsigned cookies, you can still access their values by using the
`unsigned` tag in the struct field:

```go
type MyCookies struct {
Debug bool `cookie:"user_id,unsigned"`
}
```

However you will need to explicitly override this value when setting the cookie,
as the default will be to sign the cookie:
Which will now sign all cookies by default when using the `Set` method. You can
still override this by passing `Signed: false` to the options when setting a
cookie.

```go
cookie.Set(w, "debug", "true", &cookie.Options{
Signed: false,
})
```

Due to the option now defaulting to `true`.
But will need to explicitly `GetSigned` when retrieving the value.

When defaulting to signed cookies, you can still use the `unsigned` tag in the
struct field to populate unsigned cookies:

```go
type MyCookies struct {
Debug bool `cookie:"debug,unsigned"`
}
```

0 comments on commit 06faf43

Please sign in to comment.