Skip to content

Commit

Permalink
add complete example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
chmike committed Apr 15, 2020
1 parent c7d301d commit 3c7093b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ if err := obj.Delete(w); err != nil {
**Note:** don't rely on the assumption that the remote user agent (browser) will
effectively delete the cookie. Evil users will try anything to break your site.

### Complete example

An complete example is provided [here](http://github.com/chmike/securecookie/example/main.go).

Follow these steps to test the example:

1. create a directory in /tmp and set it as the working directory: "mkdir /tmp/sctest; cd /tmp/sctest"
2. create a file named `main.go` and copy the example code referenced above into it
3. create a go.mod file: "go mod init example.com"
4. run the server: "go run main.go"
5. with your browser, request "http://localhost:8080/set/someValue" to set the secure cookie value
6. with your browser, request "http://localhost:8080/val" to retriev the secure cookie value

## Benchmarking

Encoding the cookie named "test" with value "some value". See benchmark functions
Expand Down

0 comments on commit 3c7093b

Please sign in to comment.