An open API service providing repository metadata for many open source software ecosystems.

Package Usage: go: github.com/gorilla/sessions

Package sessions provides cookie and filesystem sessions and infrastructure for custom session backends. The key features are: Let's start with an example that shows the sessions API in a nutshell: First we initialize a session store calling NewCookieStore() and passing a secret key used to authenticate the session. Inside the handler, we call store.Get() to retrieve an existing session or a new one. Then we set some session values in session.Values, which is a map[interface{}]interface{}. And finally we call session.Save() to save the session in the response. Note that in production code, we should check for errors when calling session.Save(r, w), and either display an error message or otherwise handle it. Save must be called before writing to the response, otherwise the session cookie will not be sent to the client. That's all you need to know for the basic usage. Let's take a look at other options, starting with flash messages. Flash messages are session values that last until read. The term appeared with Ruby On Rails a few years back. When we request a flash message, it is removed from the session. To add a flash, call session.AddFlash(), and to get all flashes, call session.Flashes(). Here is an example: Flash messages are useful to set information to be read after a redirection, like after form submissions. There may also be cases where you want to store a complex datatype within a session, such as a struct. Sessions are serialised using the encoding/gob package, so it is easy to register new datatypes for storage in sessions: As it's not possible to pass a raw type as a parameter to a function, gob.Register() relies on us passing it a value of the desired type. In the example above we've passed it a pointer to a struct and a pointer to a custom type representing a map[string]interface. (We could have passed non-pointer values if we wished.) This will then allow us to serialise/deserialise values of those types to and from our sessions. Note that because session values are stored in a map[string]interface{}, there's a need to type-assert data when retrieving it. We'll use the Person struct we registered above: By default, session cookies last for a month. This is probably too long for some cases, but it is easy to change this and other attributes during runtime. Sessions can be configured individually or the store can be configured and then all sessions saved using it will use that configuration. We access session.Options or store.Options to set a new configuration. The fields are basically a subset of http.Cookie fields. Let's change the maximum age of a session to one week: Sometimes we may want to change authentication and/or encryption keys without breaking existing sessions. The CookieStore supports key rotation, and to use it you just need to set multiple authentication and encryption keys, in pairs, to be tested in order: New sessions will be saved using the first pair. Old sessions can still be read because the first pair will fail, and the second will be tested. This makes it easy to "rotate" secret keys and still be able to validate existing sessions. Note: for all pairs the encryption key is optional; set it to nil or omit it and and encryption won't be used. Multiple sessions can be used in the same request, even with different session backends. When this happens, calling Save() on each session individually would be cumbersome, so we have a way to save all sessions at once: it's sessions.Save(). Here's an example: This is possible because when we call Get() from a session store, it adds the session to a common registry. Save() uses it to save all registered sessions.
8 versions
Latest release: 9 months ago
2,897 dependent packages

View more package details: https://packages.ecosyste.ms/registries/proxy.golang.org/packages/github.com/gorilla/sessions

View more repository details: http://repos.ecosyste.ms/hosts/GitHub/repositories/gorilla%2Fsessions

Dependent Repos 20,076

ossf/scorecard-action
Official GitHub Action for OpenSSF Scorecard.

Size: 6.93 MB - Last synced: 7 days ago - Pushed: 11 days ago

aberja/argo Fork of argoproj/argo-workflows
Argo Workflows: Get stuff done with Kubernetes.

Size: 66.8 MB - Last synced: 11 months ago - Pushed: about 2 years ago

krasish/test-infra Fork of kyma-project/test-infra
Test infrastructure for the Kyma project.

Size: 15.3 MB - Last synced: about 2 years ago - Pushed: about 2 years ago

ryanlycch/go-zero-looklook Fork of Mikaelemmmm/go-zero-looklook
🔥基于go-zero(go zero) 微服务全技术栈开发最佳实践项目。Develop best practice projects based on the full technology stack of go zero (go zero) microservices.

Size: 101 MB - Last synced: 4 months ago - Pushed: 4 months ago

observIQ/grafana-agent Fork of grafana/agent
Telemetry agent for the LGTM stack.

Size: 48.3 MB - Last synced: over 1 year ago - Pushed: over 1 year ago

DurkaVerder/Expense-Tracker-API

Size: 6.84 KB - Last synced: 6 months ago - Pushed: 6 months ago

tharun208/loki Fork of grafana/loki
Like Prometheus, but for logs.

Size: 168 MB - Last synced: about 1 year ago - Pushed: about 2 years ago

wiennat/rjio

Size: 16.3 MB - Last synced: 11 months ago - Pushed: about 2 years ago

go-farmyard/farmyard

Size: 32.2 KB - Last synced: 11 months ago - Pushed: 12 months ago

KauzClay/net-kourier Fork of knative-sandbox/net-kourier
Purpose-built Knative Ingress implementation using just Envoy with no additional CRDs

Size: 35.4 MB - Last synced: almost 2 years ago - Pushed: about 2 years ago

msrinivasssa/go-trial-app

Size: 397 KB - Last synced: about 2 years ago - Pushed: about 2 years ago

jrivera-px/operator Fork of libopenstorage/operator
Storage operator for Kubernetes

Size: 34.9 MB - Last synced: about 2 years ago - Pushed: about 2 years ago

paketo-buildpacks/go
A Cloud Native Buildpack for Go

Size: 83 MB - Last synced: 14 days ago - Pushed: 14 days ago

mdisibio/tempo Fork of grafana/tempo
Grafana Tempo is a high volume, minimal dependency trace storage.

Size: 159 MB - Last synced: 4 days ago - Pushed: 4 days ago

paketo-buildpacks/dotnet-core
A Cloud Native Buildpack for .NET Core

Size: 176 MB - Last synced: 2 days ago - Pushed: 2 days ago

companieshouse/insolvency-api

Size: 1.07 MB - Last synced: about 1 month ago - Pushed: about 1 month ago

drh-determined-ai/determined Fork of determined-ai/determined
Determined: Deep Learning Training Platform

Size: 114 MB - Last synced: 11 months ago - Pushed: over 1 year ago

Shashankreddysunkara/NavVis-go-webapp

Size: 483 KB - Last synced: about 1 month ago - Pushed: about 2 years ago

sknot-rh/kubernetes-client Fork of fabric8io/kubernetes-client
Java client for Kubernetes & OpenShift

Size: 442 MB - Last synced: about 2 years ago - Pushed: over 2 years ago

tts-tblock/kubernetes-client Fork of fabric8io/kubernetes-client
Java client for Kubernetes & OpenShift

Size: 449 MB - Last synced: about 2 years ago - Pushed: about 2 years ago

trustbloc/auth 📦
Authorization Server

Size: 2.24 MB - Last synced: 10 months ago - Pushed: about 2 years ago

Quiq/webauthn_proxy
Proxy for enforcing webauthn authentication

Size: 5.36 MB - Last synced: about 1 month ago - Pushed: about 1 month ago

okteto/microservices-demo
A sample application with Go, Java, Javascript, Kafka and Postgres

Size: 2.4 MB - Last synced: 2 months ago - Pushed: 2 months ago

ankitm123/jx-pipeline Fork of jenkins-x-plugins/jx-pipeline
a small binary plugin for working with Jenkins X pipelines

Size: 2.02 MB - Last synced: 28 days ago - Pushed: 28 days ago

strimzi/strimzi-canary 📦
Strimzi canary

Size: 325 KB - Last synced: 19 days ago - Pushed: 7 months ago

boostchicken/opentelemetry-collector-contrib Fork of open-telemetry/opentelemetry-collector-contrib
Contrib repository for the OpenTelemetry Collector

Size: 262 MB - Last synced: 11 months ago - Pushed: over 1 year ago

ankitm123/jx-registry Fork of jenkins-x-plugins/jx-registry
a plugin for working with container registries

Size: 331 KB - Last synced: 28 days ago - Pushed: 28 days ago

burhankangsi/Flash-API

Size: 34.2 KB - Last synced: 11 months ago - Pushed: almost 3 years ago

SadmiB/seaweedfs Fork of seaweedfs/seaweedfs
SeaweedFS is a fast distributed storage system for blobs, objects, files, and data lake, for billions of files! Blob store has O(1) disk seek, cloud tiering. Filer supports Cloud Drive, cross-DC active-active replication, Kubernetes, POSIX FUSE mount, S3 API, S3 Gateway, Hadoop, WebDAV, encryption, Erasure Coding.

Size: 40.6 MB - Last synced: about 2 years ago - Pushed: about 2 years ago

kubernetes/node-problem-detector
This is a place for various problem detectors running on the Kubernetes nodes.

Size: 30.1 MB - Last synced: 9 days ago - Pushed: 10 days ago

pokearu/cluster-api-provider-tinkerbell Fork of tinkerbell/cluster-api-provider-tinkerbell
Cluster API Infrastructure Provider for Tinkerbell

Size: 1.12 MB - Last synced: almost 2 years ago - Pushed: almost 2 years ago

giftxtrade/api
GiftTrade RESTful API built with Go

Size: 1.17 MB - Last synced: 6 months ago - Pushed: 6 months ago

partitio/dex Fork of dexidp/dex
OpenID Connect Identity (OIDC) and OAuth 2.0 Provider with Pluggable Connectors

Size: 23 MB - Last synced: 11 months ago - Pushed: over 2 years ago

wantonbe/private-isu Fork of catatsuy/private-isu
社内ISUCON

Size: 2.93 MB - Last synced: about 2 years ago - Pushed: almost 3 years ago

fabriziosestito/trento Fork of trento-project/trento 📦
An open cloud-native web console improving on the life of SAP Applications administrators.

Size: 22.4 MB - Last synced: about 1 year ago - Pushed: almost 3 years ago

jeschkies/loki Fork of grafana/loki
Like Prometheus, but for logs.

Size: 288 MB - Last synced: 10 days ago - Pushed: 10 days ago

no-src/gofs
A cross-platform real-time file synchronization tool out of the box based on Golang

Size: 1.33 MB - Last synced: 6 months ago - Pushed: 6 months ago

NikitaSkrynnik/sdk-sriov Fork of networkservicemesh/sdk-sriov
SR-IOV related SDK components

Size: 1.18 MB - Last synced: 11 months ago - Pushed: about 1 year ago

sanekkurt/telegraf Fork of influxdata/telegraf
The plugin-driven server agent for collecting & reporting metrics.

Size: 43.5 MB - Last synced: about 2 years ago - Pushed: almost 3 years ago

chf007/argo-workflows Fork of argoproj/argo-workflows
Workflow engine for Kubernetes

Size: 81.6 MB - Last synced: 5 months ago - Pushed: about 2 years ago

planetary-social/scuttlego
A Go implementation of the Secure Scuttlebutt protocol.

Size: 4.51 MB - Last synced: 7 days ago - Pushed: about 2 years ago

skryun/go-fly Fork of taoshihan1991/go-fly
开源客服系统GO语言开发GO-FLY,免费客服系统/open source live customer chat by golang

Size: 13.7 MB - Last synced: over 1 year ago - Pushed: over 1 year ago

flagship-io/flagship-go-sdk

Size: 2.45 MB - Last synced: 6 months ago - Pushed: about 2 years ago