1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
# Rack::Session
Session management implementation for Rack.
[](https://github.com/rack/rack-session/actions?workflow=Test)
## Usage
In your `config.ru`:
``` ruby
# config.ru
require 'rack/session'
use Rack::Session::Cookie,
:domain => 'mywebsite.com',
:path => '/',
:expire_after => 3600*24,
:secret => '**unique secret key**'
```
Usage follows the standard outlined by `rack.session`, i.e.:
``` ruby
class MyApp
def call(env)
session = env['rack.session']
# Set some state:
session[:key] = "value"
end
end
```
### Compatibility
`rack-session` code used to be part of Rack, but it was extracted in Rack v3 to this gem. The v1 release of this gem is compatible with Rack v2, and the v2 release of this gem is compatible with Rack v3+. That means you can add `gem "rack-session"` to your application and it will be compatible with all versions of Rack.
## Contributing
We welcome contributions to this project.
1. Fork it.
2. Create your feature branch (`git checkout -b my-new-feature`).
3. Commit your changes (`git commit -am 'Add some feature'`).
4. Push to the branch (`git push origin my-new-feature`).
5. Create new Pull Request.
|