README.md

# PlugSessionRedisStore

> Extendable Redis store for Plug.Session

[![Build Status][travis-image]][travis-url]

## Abstract

This library is a dummy connector between Plug and Redis, nothing more.
It allows the configuration of the session ID generation, data serialization and
Redis connection.

## Installation

Declare the dependency on your `mix.exs` file.
```elixir
def deps do
  [
    {:plug_session_redis_store, "~> 0.1.0"}
  ]
end
```

## Configuration

### PlugSessionRedisStore
```elixir
condig :plug_session_redis_store,
  sid_generator: PlugSessionRedisStore.Generator.StrongRandBytes,
  encoder: PlugSessionRedisStore.Encoder.Binary,
  redis: [
    host: "localhost",
    database: 2
  ]
```

- `sid_generator`: Session ID Generator (default RandBytes)
- `encoder`: Session Data Serializer (default Binary)
- `redis`: Redis Connection. This configuration is forwarded as is to `Redix` ([redix-configuration]).

### Plug
```elixir
plug Plug.Session,
  store: :redis,
  key: "SSID",
  max_age: 2_592_000, # Optional - default 30 days
  secure: true,
  http_only: true,
  signing_salt: "some $3cr3t salt key" # change this value
```

**NOTE:** PlugSessionRedisStore relies on the Plug configuration when it comes to handling session expiration.
The duration is directly tied to the cookie one.  Like the cookie, the session expiration is reset upon each request.

## Contributing

1. Fork it (<https://github.com/gearnode/judge/fork>)
2. Create your feature branch (`git checkout -b feature/fooBar`)
3. Commit your changes (`git commit -am 'Add some fooBar'`)
4. Push to the branch (`git push origin feature/fooBar`)
5. Create a new Pull Request

<!-- Markdown link & img dfn's -->
[travis-image]: https://travis-ci.com/jobteaser/plug_session_redis_store.svg?branch=master
[travis-url]: https://travis-ci.org/jobteaser/plug_session_redis_store
[redix-configuration]: https://hexdocs.pm/redix/Redix.html#start_link/2