Created
February 10, 2012 17:17
-
-
Save ngauthier/1791046 to your computer and use it in GitHub Desktop.
Anonymous session id in rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
def anonymous_id | |
if !session.has_key? :session_id | |
# LAME we have to write to the session to get it to initialize itself | |
# the following line could be anything that writes to the session | |
# except don't write to session_id, because that's what we need | |
session[:id] = session[:id] | |
end | |
session[:session_id] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment