Sha256: 9c8c65321321dbc58cf36a2900a2eda641aef6a5c30a1d7ac443016f50f30203
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
module Galakei::SessionIdParameter::InUrl if Rails::VERSION::MINOR == 0 ENV_SESSION_OPTIONS_KEY = ActionDispatch::Session::AbstractStore::ENV_SESSION_OPTIONS_KEY else require "rack/session/abstract/id.rb" ENV_SESSION_OPTIONS_KEY = Rack::Session::Abstract::ENV_SESSION_OPTIONS_KEY end def url_for(options = {}) return super unless inject_session_id_parameter?(options) session_opts = request.env[ENV_SESSION_OPTIONS_KEY] # if we don't have a session ID yet, create one if session_opts[:id].blank? # make sure to reset any active record session store, # we'll have to create a new one for the new session request.env[ActiveRecord::SessionStore::SESSION_RECORD_KEY] = nil if defined?(ActiveRecord) # create a new session ID session_opts[:id] = ActiveSupport::SecureRandom.hex(8) end super(options.merge(::Rails.application.config.session_options[:key] => session_opts[:id])) end private def inject_session_id_parameter?(options) return false unless options.is_a?(Hash) && request return true if request.imode_browser_1_0? # cookies on older AU handsets using SSL are unreliable return true if request.au_browser_6? && request.ssl? # au and softbank have two forms of cookies depending on if it is # http or https, so carry over session id when switching protocols return false unless options[:protocol] request.different_cookie_in_ssl? && (request.protocol != options[:protocol]) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
galakei-0.13.0 | lib/galakei/session_id_parameter/in_url.rb |
galakei-0.12.1 | lib/galakei/session_id_parameter/in_url.rb |
galakei-0.12.0 | lib/galakei/session_id_parameter/in_url.rb |