Repository is archived
No commit activity in last 3 years
No release in over 3 years
session_jsonizer is a simple library for Rails 3 and 4 to serialize session as JSON in the same format.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.1.0
 Project Readme

rails-session_jsonizer

rails-session_jsonizer is a simple library for Rails 3 and 4 to serialize session into JSON in the same format.

Work in progress

Build Status

Requirement

  • Rails 3.1 or later

Usage

In controller

session[:foo] = 'bar'
flash[:alert] = 'something went wrong'

Serialize

require 'session_jsonizer'

# dump
serializer = SessionJsonizer.new

json = serializer.dump(session)

json # => '{"foo":"bar", "flash":{"alert":"something went wrong"}, ...}'

# load
session = serializer.load(json)

Example: Store session into memcached as JSON using dalli

# config/initializers/session_store.rb

require 'action_dispatch/middleware/session/dalli_store'
Rails.application.config.session_store :dalli_store, serializer: SessionJsonizer.new, ...