lib/hayabusa_ext/sessions.rb in hayabusa-0.0.20 vs lib/hayabusa_ext/sessions.rb in hayabusa-0.0.22
- old
+ new
@@ -1,6 +1,8 @@
class Hayabusa
+ attr_reader :sessions
+
def initialize_sessions
@sessions = Tsafe::MonHash.new
end
#Returns or adds session based on idhash and meta-data.
@@ -11,12 +13,15 @@
session = @ob.get_by(:Session, "idhash" => idhash)
if !session
session = @ob.add(:Session, {
:idhash => idhash,
:user_agent => meta["HTTP_USER_AGENT"],
- :ip => ip
+ :ip => ip,
+ :date_lastused => Time.now
})
+ else
+ session[:date_lastused] = Time.now
end
hash = {}
@sessions[idhash] = {
:dbobj => session,
@@ -26,11 +31,9 @@
session = @sessions[idhash][:dbobj]
hash = @sessions[idhash][:hash]
end
raise ArgumentError, "Invalid IP." if ip != "bot" and !session.remember? and ip.to_s != session[:ip].to_s
-
- @sessions[idhash][:time_lastused] = Time.now
return [session, hash]
end
#Generates a new session-ID by the meta data.
def session_generate_id(meta)
\ No newline at end of file