3 #You might want to change this
4 #ENV["RAILS_ENV"] ||= "development"
6 require File.dirname(__FILE__) + "/../../config/environment"
12 session_path = ActionController::Base.session_options[:tmpdir]
14 def expire_session(name)
15 ActiveRecord::Base.logger.info("Expiring session #{File.basename(name)}")
20 Dir.foreach(session_path) do |session_name|
21 if session_name =~ /^ruby_sess\./
22 session_name = session_path + "/" + session_name
23 session = PStore.new(session_name)
25 session.transaction do |session|
26 session_hash = session['hash']
29 session_stat = File::Stat.new(session_name)
30 puts session_hash[:token]
32 if session_hash[:token] and User.find_by_token(session_hash[:token])
33 # expire_session(session_name) if session_stat.mtime < 1.day.ago
35 expire_session(session_name) if session_stat.mtime < 1.hour.ago
38 expire_session(session_name)