Reputation: 15127
I am trying to track kiss_metrics
identifier and would like to maintain the same unique_identifier
for the user throughout their entire time they are on the site, even after call reset_session
.
Something like a cookie_id
that is the same from login to logout and the entire time they are on the site?
Upvotes: 1
Views: 70
Reputation: 4966
I would do it this way:
First, add your own token to the session on login using SecureRandom.uuid. Doing this makes sure it's not going to get messed with by other parts of Rails (you don't know when the csrf token gets nuked, for example).
Instead of calling reset_session
call a wrapper that maintains your unique token:
def clear_session_except_token
token = session[:token]
clear_session
session[:token] = token
end
You can then clear the token when the user logs out.
Upvotes: 1