Skip to content

Commit

Permalink
Merge pull request rails#44423 from jonathanhefner/guides-update-sess…
Browse files Browse the repository at this point in the history
…ion_store-instructions

Update `session_store` configuration instructions [ci-skip]
  • Loading branch information
jonathanhefner committed Feb 14, 2022
2 parents 086935e + 7e7552b commit 1fb6d1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 13 additions & 8 deletions guides/source/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,22 @@ Configures Rails to serve static files from the public directory. This option de

#### `config.session_store`

Specifies what class to use to store the session. Possible values are `:cookie_store` which is the default, `:mem_cache_store`, and `:disabled`. The last one tells Rails not to deal with sessions. Defaults to a cookie store with application name as the session key. Custom session stores can also be specified:
Specifies what class to use to store the session. Possible values are `:cookie_store`, `:mem_cache_store`, a custom store, or `:disabled`. `:disabled` tells Rails not to deal with sessions.

This setting is configured via a regular method call, rather than a setter. This allows additional options to be passed:

```ruby
config.session_store :cookie_store, key: "_your_app_session"
```

If a custom store is specified as a symbol, it will be resolved to the `ActionDispatch::Session` namespace:

```ruby
# use ActionDispatch::Session::MyCustomStore as the session store
config.session_store :my_custom_store
```

This custom store must be defined as `ActionDispatch::Session::MyCustomStore`.
The default store is a cookie store with the application name as the session key.

#### `config.ssl_options`

Expand Down Expand Up @@ -572,11 +581,11 @@ Sets cookies for the request.

#### `ActionDispatch::Session::CookieStore`

Is responsible for storing the session in cookies. An alternate middleware can be used for this by changing the `config.action_controller.session_store` to an alternate value. Additionally, options passed to this can be configured by using `config.action_controller.session_options`.
Is responsible for storing the session in cookies. An alternate middleware can be used for this by changing [`config.session_store`](#config-session-store).

#### `ActionDispatch::Flash`

Sets up the `flash` keys. Only available if `config.action_controller.session_store` is set to a value.
Sets up the `flash` keys. Only available if [`config.session_store`](#config-session-store) is set to a value.

#### `Rack::MethodOverride`

Expand Down Expand Up @@ -1148,10 +1157,6 @@ the top level, or on individual controllers.

### Configuring Action Dispatch

#### `config.action_dispatch.session_store`

Sets the name of the store for session data. The default is `:cookie_store`; other valid options include `:active_record_store`, `:mem_cache_store` or the name of your own custom class.

#### `config.action_dispatch.cookies_serializer`

Specifies which serializer to use for cookies. For more information, see [Action Controller Cookies](action_controller_overview.html#cookies).
Expand Down
4 changes: 3 additions & 1 deletion guides/source/rails_on_rack.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ Much of Action Controller's functionality is implemented as Middlewares. The fol

**`ActionDispatch::Flash`**

* Sets up the flash keys. Only available if `config.action_controller.session_store` is set to a value.
* Sets up the flash keys. Only available if [`config.session_store`][] is set to a value.

[`config.session_store`]: configuring.html#config-session-store

**`ActionDispatch::ContentSecurityPolicy::Middleware`**

Expand Down

0 comments on commit 1fb6d1b

Please sign in to comment.