SkillAgentSearch skills...

Sessions

Martini handler that provides a Session service.

Install / Use

/learn @martini-contrib/Sessions
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

sessions wercker status

Martini middleware/handler for easy session management.

API Reference

Usage

package main

import (
  "github.com/go-martini/martini"
  "github.com/martini-contrib/sessions"
)

func main() {
	m := martini.Classic()

	store := sessions.NewCookieStore([]byte("secret123"))
	m.Use(sessions.Sessions("my_session", store))

	m.Get("/set", func(session sessions.Session) string {
		session.Set("hello", "world")
		return "OK"
	})

	m.Get("/get", func(session sessions.Session) string {
		v := session.Get("hello")
		if v == nil {
			return ""
		}
		return v.(string)
	})

  m.Run()
}

Authors

View on GitHub
GitHub Stars71
CategoryDevelopment
Updated1y ago
Forks38

Languages

Go

Security Score

80/100

Audited on Jan 10, 2025

No findings