All Projects → gorilla → Sessions

gorilla / Sessions

Licence: bsd-3-clause
Package gorilla/sessions provides cookie and filesystem sessions and infrastructure for custom session backends.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Sessions

Redux Cookies Middleware
redux-cookies-middleware is a Redux middleware which syncs a subset of your Redux store state with cookies.
Stars: ✭ 75 (-96.51%)
Mutual labels:  cookie
Auth Module
auth.nuxtjs.org
Stars: ✭ 1,624 (-24.39%)
Mutual labels:  cookie
Electrode Csrf Jwt
Stateless Cross-Site Request Forgery (CSRF) protection with JWT
Stars: ✭ 127 (-94.09%)
Mutual labels:  cookie
Wstest
go websocket client for unit testing of a websocket handler
Stars: ✭ 83 (-96.14%)
Mutual labels:  gorilla
Wyycg Autocheckin
✨白嫖小助手提醒您:今天你白嫖网易云游戏了吗?快来跟我一起白嫖网易云游戏,成为云游戏长期在线用户吧!
Stars: ✭ 94 (-95.62%)
Mutual labels:  cookie
Pat
a pretty simple HTTP router for Go.
Stars: ✭ 113 (-94.74%)
Mutual labels:  gorilla
Pgstore
A Postgres session store backend for gorilla/sessions
Stars: ✭ 66 (-96.93%)
Mutual labels:  gorilla
Curlsharp
CurlSharp - .Net binding and object-oriented wrapper for libcurl.
Stars: ✭ 153 (-92.88%)
Mutual labels:  cookie
Web Analytics
监测分析、异常监测、广告验证、访客唯一标识
Stars: ✭ 97 (-95.48%)
Mutual labels:  cookie
Cookie Parser
Parse HTTP request cookies
Stars: ✭ 1,683 (-21.65%)
Mutual labels:  cookie
Localslackirc
IRC gateway for slack, running on localhost for one user
Stars: ✭ 84 (-96.09%)
Mutual labels:  cookie
Review reverse
👋2019年末总结下今年做过的逆向,整理代码,复习思路。🙏拼夕夕Web端anti_content参数逆向分析👺 WEB淘宝sign逆向分析;😺努比亚Cookie生成逆向分析;🙌百度指数data加密逆向分析 👣今日头条WEB端_signature、as、cp参数逆向分析🎶知乎登录formdata加密逆向分析 🤡KNN猫眼字体反爬👅Boss直聘Cookie加密字段__zp_stoken__逆向分析
Stars: ✭ 1,302 (-39.39%)
Mutual labels:  cookie
Ngx Cookieconsent
Cookie 🍪 Consent module for Angular.
Stars: ✭ 120 (-94.41%)
Mutual labels:  cookie
Gowebsocket
Gorilla websockets based simplified websocket-client implementation in GO.
Stars: ✭ 77 (-96.42%)
Mutual labels:  gorilla
Android Cookie Store
Android InMemory and persistent Cookie Store for HttpURLConnection and OkHttp, with extensions to easily sync cookies in Android WebViews.
Stars: ✭ 144 (-93.3%)
Mutual labels:  cookie
Handlers
A collection of useful middleware for Go HTTP services & web applications 🛃
Stars: ✭ 1,174 (-45.34%)
Mutual labels:  gorilla
Angular2 Cookie
Implementation of Angular 1.x $cookies service to Angular 2
Stars: ✭ 112 (-94.79%)
Mutual labels:  cookie
Vue Warehouse
A Cross-browser storage for Vue.js and Nuxt.js, with plugins support and easy extensibility based on Store.js.
Stars: ✭ 161 (-92.5%)
Mutual labels:  cookie
Rack Policy
Rack middleware for the EU ePrivacy Directive compliance in Ruby Web Apps
Stars: ✭ 149 (-93.06%)
Mutual labels:  cookie
Cookiescanner
Cookie Scanner for GDPR compliance
Stars: ✭ 126 (-94.13%)
Mutual labels:  cookie

sessions

GoDoc Build Status Sourcegraph

gorilla/sessions provides cookie and filesystem sessions and infrastructure for custom session backends.

The key features are:

  • Simple API: use it as an easy way to set signed (and optionally encrypted) cookies.
  • Built-in backends to store sessions in cookies or the filesystem.
  • Flash messages: session values that last until read.
  • Convenient way to switch session persistency (aka "remember me") and set other attributes.
  • Mechanism to rotate authentication and encryption keys.
  • Multiple sessions per request, even using different backends.
  • Interfaces and infrastructure for custom session backends: sessions from different stores can be retrieved and batch-saved using a common API.

Let's start with an example that shows the sessions API in a nutshell:

	import (
		"net/http"
		"github.com/gorilla/sessions"
	)

	// Note: Don't store your key in your source code. Pass it via an
	// environmental variable, or flag (or both), and don't accidentally commit it
	// alongside your code. Ensure your key is sufficiently random - i.e. use Go's
	// crypto/rand or securecookie.GenerateRandomKey(32) and persist the result.
	var store = sessions.NewCookieStore([]byte(os.Getenv("SESSION_KEY")))

	func MyHandler(w http.ResponseWriter, r *http.Request) {
		// Get a session. We're ignoring the error resulted from decoding an
		// existing session: Get() always returns a session, even if empty.
		session, _ := store.Get(r, "session-name")
		// Set some session values.
		session.Values["foo"] = "bar"
		session.Values[42] = 43
		// Save it before we write to the response/return from the handler.
		err := session.Save(r, w)
		if err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
	}

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 create 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.

More examples are available on the Gorilla website.

Store Implementations

Other implementations of the sessions.Store interface:

License

BSD licensed. See the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].