99miles
99miles

Reputation: 11212

active_record_store is set but cookie still created

I have this in session_store.rb

Trunk::Application.config.session_store :active_record_store, :key => '_eg2_session_id', :domain => domain

And I ran the session migration. The session table is there and records are getting created in it, however cookies are also getting created. Any idea why?

Upvotes: 0

Views: 673

Answers (1)

Emily
Emily

Reputation: 18193

The cookie is still required to map the user visiting the site to the session in the database. What you're changing when you change the session_store is where the data is stored.

So, the way you have things set up, this is roughly what happens:

  • User visits the site
  • Session created in database
  • Cookie created with session ID
  • You store user_id => 5 in the session, and that's added to the database

When you use cookie store, here's what happens:

  • User visits the site
  • Cookie created with session data
  • You store user_id => 5 in the session, and that's added to the cookie

In both cases, a cookie is created to associate the visitor with the session, it's just that the data in the session is stored in a different place.

Upvotes: 1

Related Questions