Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8911247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:53:38+00:00 2026-06-15T03:53:38+00:00

By default, rails uses cookie storage for session information. The tutorial I followed said

  • 0

By default, rails uses cookie storage for session information. The tutorial I followed said that it was the best way and super fast, and that it all gets encrypted. But when I base64 decode the cookie content, I can see my session info there. It’s mixed into a lot of garbled characters, but it’s there.

What am I missing here?

Doesn’t rails use that secret token thing to encrypt the info in the cookie? How can I make it do so?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:53:39+00:00Added an answer on June 15, 2026 at 3:53 am

    Rails uses a secret token to sign the session. The raw data is still there, but changing it will cause it to not match the signature any more, and Rails will reject it. The cookie string looks like session_data--signature, the session data is a base64-encoded marshalled object, and the signature is HMAC(session string, secret token).

    The general assumption of the session data is that it is not secret (since it generally should contain only a few things, like a CSRF token and a user ID), but it should not be changeable by a user. The cookie signing accomplishes this.

    If you need to actually encrypt the data so that users could never see it, you could do so using something like OpenSSL symmetric encryption, or you could switch to a non-cookie data store.

    This is a variant on my own app’s cookie store; I haven’t tested it, but in theory this should generate actually-encrypted cookies for you. Note that this will be appreciably slower than the default cookie store, and depending on its runtime, could potentially be a DOS vector. Additionally, encrypted data will be lengthier than unencrypted data, and session cookies have a 4kb limit, so if you’re storing a lot of data in your session, this might cause you to blow past that limit.

    # Define our message encryptor
    module ActiveSupport
      class EncryptedMessageVerifier < MessageVerifier
        def verify(message)
          Marshal.load cryptor.decrypt_and_verify(message)
        end
    
        def generate(value)
          cryptor.encrypt_and_sign Marshal.dump(value)
        end
    
        def cryptor
          ActiveSupport::MessageEncryptor.new(@secret)
        end
      end
    end
    
    # And then patch it into SignedCookieJar
    class ActionDispatch::Cookies::SignedCookieJar
      def initialize(parent_jar, secret)
        ensure_secret_secure(secret)
        @parent_jar = parent_jar
        @verifier   = ActiveSupport::EncryptedMessageVerifier.new(secret)
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't like the way rails does page titles by default (just uses the
Using Rails 3.1.3 with Ruby 1.9.3p0. I've discovered that by default, Rails does not
Recently I have started learning rails and was a little surprised that the default
Does anyone know if Rails can be configured so that rake (e.g. db:migrate) uses
we are currently working on a rails project that uses i18n and we have
I have a rails app that uses Devise for user auth. In localhost:3000 my
The default way to output JSON in rails is some thing like: Code: render
I've started a new rails 3.2 project and by default it uses SQLite. I
I have implemented web service using rails server. The server uses rails default authentication
Rails 3 uses a default DOCTYPE of HTML 5: <!DOCTYPE html> except a few

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.