Sha256: dda919c4808e386fa6590933e23c42e76d76da8ef070464593e702e1ef084801

Contents?: true

Size: 989 Bytes

Versions: 7

Compression:

Stored size: 989 Bytes

Contents

# frozen_string_literal: true

module Firebug
  require 'active_record'

  # An ActiveRecord model of the CodeIgniter sessions table.
  class Session < ActiveRecord::Base
    self.table_name = 'default_ci_sessions'

    # @return [Object]
    def user_data
      Firebug.unserialize(super || '')
    end

    # @param [Object] value
    def user_data=(value)
      super(Firebug.serialize(value))
    end

    # @param [String] value
    def user_agent=(value)
      # Pyro seems to truncate the value and since it also uses this value when finding the session, it's important
      # we do the same.
      super(Firebug.configuration.truncate_useragent ? value[0...120] : value)
    end

    # @return [String]
    def cookie_data
      data = { session_id: session_id, ip_address: ip_address, user_agent: user_agent, last_activity: last_activity }
      Firebug.encrypt_cookie(data)
    end

    private

    def timestamp_attributes_for_update
      ['last_activity']
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
firebug-0.1.7 lib/firebug/session.rb
firebug-0.1.6 lib/firebug/session.rb
firebug-0.1.5 lib/firebug/session.rb
firebug-0.1.4 lib/firebug/session.rb
firebug-0.1.3 lib/firebug/session.rb
firebug-0.1.2 lib/firebug/session.rb
firebug-0.1.1 lib/firebug/session.rb