How force that session is loaded?

后端 未结 4 849
南旧
南旧 2020-12-03 10:47

I\'m working on an application that needs to use session id information. My session is stored in cookies. The problem I have is that my session is not immediately available

4条回答
  •  不思量自难忘°
    2020-12-03 11:17

    Here's some relevant code from ActionDispatch::Session:

     def [](key)
        load_for_read!
        @delegate[key.to_s]
      end
    
      private
    
      def load_for_read!
        load! if !loaded? && exists?
      end
    

    Which implies that the session object will be loaded as soon as you access any value by its key via [].

提交回复
热议问题