Skip to content

Commit

Permalink
Added documentation for new session feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Mikusa authored and davidjahn committed Apr 11, 2016
1 parent 2e4148a commit 89377df
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Here are some special features of the buildpack.
- Supports an extension mechanism that allows the buildpack to provide additional functionality.
- Allows for application developers to provide custom extensions.
- Easy troubleshooting with the `BP_DEBUG` environment variable.
- Download location is configurable, allowing users to host binaries on the same network (i.e. run without an Internet connection)
- Smart session storage, defaults to file w/sticky sessions but can also use redis for storage.

## Examples

Expand Down
30 changes: 30 additions & 0 deletions docs/sessions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Sessions

When your application has one instance, it's mostly safe to use the default session storage, which is the local file system. You would only see problems if your single instance crashes as the local file system would go away and you'd lose your sessions. For many applications, this will work just fine but please consider how this will impact your application.

If you have multiple application instances or you need a more robust solution for your application, then you'll want to use Redis or Memcached as a backing store for your session data. The build pack supports both and when one is bound to your application it will detected it and automatically configure PHP to use it for session storage.

### Usage

By default, there's no configuration necessary. Simple create a Redis service, make sure the service name contains `redis-sessions` and then bind the service to the application.

Ex:

```
cf create-service redis some-plan app-redis-sessions
cf bind-service app app-redis-sessions
cf restage app
```

If you want to use a specific service instance or change the search key, you can do that by setting `REDIS_SESSION_STORE_SERVICE_NAME` in `.bp-config/options.json` to the new search key. The session configuration extension will then search the bound services by name for the new session key.

### Configuration Changes

When detected, the following changes will be made.

#### Redis

- the `redis` PHP extension will be installed, which provides the session save handler
- `session.name` will be set to `PHPSESSIONID` this disables sticky sessions
- `session.save_handler` is configured to `redis`
- `session.save_path` is configured based on the bound credentials (i.e. `tcp://host:port?auth=pass`)

0 comments on commit 89377df

Please sign in to comment.