Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Prevent session dumps from search robots
4 Posts
Prevent session dumps from search robots

I have an ecommerce site,

recently am having issues with clearing session objects dumped by search robots. Collectively they constitute about 60% of the total user sessions created.

I need an effective way to handle this. Would having session expire time settings help?

I am using Rails 1.2.3

Person
Forum Rating: 100
Sign In To Rate Post

Balaji, does it mean you want to provide session expire time for your rails application? if so you can do it by adding a method with before filter in application.rb file.

prepend_before_filter :prepare_session def prepare_session

 if !session[:expiry_time].nil? and session[:expiry_time] < Time.now
    reset_session
 end
 session[:expiry_time] = "set time to expire"

end

by mentioning specific time to expire the session, you do it.

Thank You, Uma.

Hi Balaji,

If instead of a session expire time you are actually concerned about the number of useless session objects that get stored in your database by search engines there are a couple of options...

First, check out the build in rake tasks for sessions:

bq. ~/: rake -T | grep session rake db:sessions:clear # Clear the sessions table rake db:sessions:create # Creates a sessions migration for use with ActiveRecord::SessionStore rake tmp:clear # Clear session, cache, and socket files from tmp/ rake tmp:create # Creates tmp directories for sessions, cache, sockets, and pids rake tmp:sessions:clear # Clears all files in tmp/sessions

Second, there are plugins out there that can make the database-backed session store more intelligent. "limited_sessions":http://iprog.com/project/limited_sessions is one such plugin, I'm sure there are more out there.

Thanks for your inputs,

Kevin ......... The plugin seems to be the best shoot for this issue, especially the IP based check will help, but I'll have to hunt for one that works in rails 1.2.3

Person
Forum Rating: 100
Sign In To Rate Post
4 Posts
Login to add your message