Skip to content

Instantly share code, notes, and snippets.

@ngauthier
Created February 10, 2012 17:17
Show Gist options
  • Save ngauthier/1791046 to your computer and use it in GitHub Desktop.
Save ngauthier/1791046 to your computer and use it in GitHub Desktop.
Anonymous session id in rails
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