Skip to content

Instantly share code, notes, and snippets.

@charlespeach
Last active December 19, 2015 22:08
Show Gist options
  • Save charlespeach/6025028 to your computer and use it in GitHub Desktop.
Save charlespeach/6025028 to your computer and use it in GitHub Desktop.
How to clear sessions in rails

Resetting user sessions

First check what type of session store your application is setup for

This config usually lives here: config/initializers/session_store.rb

ApplicationName::Application.config.session_store :cookie_store, key: '_application_name_session'

Cookie based sessions:

The only control you over other peoples cookies is to invalidate them by changing the applications secret, located in config/initializers/secret_token.rb

run rake secret to generate a new token, commit the change and deploy.

Make sure that your webserver/s are restarted after deploy.

File store based sessions:

rake tmp:sessions:clear

DB store based sessions:

rake db:sessions:clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment