cookie

package
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package cookie writes and reads a (not signed and not encrypted) HTTP cookie. It is a small piece of data that a server sends to a user's web browser or other HTTP client. This way server can map HTTP traffic (which is stateless) to a specific client. Cookies are used for:

  • Session management (e.g. logins, shopping carts)
  • Personalization (e.g. user preferences, themes)
  • Tracking (recording and analyzing user behavior)-:

Based on https://www.alexedwards.net/blog/working-with-cookies-in-go

Level: intermediate Topics: web server, net/http

Index

Constants

View Source
const Name = "ExampleCookie"

Variables

This section is empty.

Functions

func Set

func Set(w http.ResponseWriter, r *http.Request)

Set adds a "Set-Cookie" header to the response and sends it to a client.

func Show added in v0.19.1

func Show(w http.ResponseWriter, r *http.Request)

Show retrieves the cookie from the "Cookie" request header and sends it back to the client in the response body.

Types

This section is empty.

Directories

Path Synopsis
Web server that sets a cookie and shows that client sent it back.
Web server that sets a cookie and shows that client sent it back.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL