Method: RubyApp::Session.generate_session_id

Defined in:
lib/ruby_app/session.rb

.generate_session_id(session) ⇒ Object



144
145
146
147
148
149
150
151
152
153
# File 'lib/ruby_app/session.rb', line 144

def self.generate_session_id(session)
  session_id = "id_#{SecureRandom.hex(RubyApp::Session.configuration._length)}"
  RubyApp::Session.lock_sessions do
    while RubyApp::Session.get_session(session_id)
      session_id = "id_#{SecureRandom.hex(RubyApp::Session.configuration._length)}"
    end
    RubyApp::Session.sessions.store(session_id, session)
    return session_id
  end
end