Skip to content
This repository has been archived by the owner on Dec 25, 2020. It is now read-only.

pixta-dev/rails-session_jsonizer

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published