I haven't dealt with that before, but if I were to do it, I would:
Determine what I meant by expired (let's say 3 days for example)
Write a rake task that deletes the session
Write a cron script to run it nightly after the database backup
My rake task would probably look like:
namespace :db
namespace :sessions
task :delete => :environment do
CGI::Session::ActiveRecordStore::Session.delete_all(['created_at < ?',
3.days.ago])
end
end
end
My cron script would look something like this:
mkdir -p /var/backup/mysql
date=`date "+%d"`
mysqldump -ubackup -pmypass myapp_production | gzip > /var/backup/
mysql/myapp-$date.sql.gz
cd /var/www/apps/myapp/current && rake db:sessions:delete
Alternately, you could have it run every time an admin logs in
(assuming that your admins don't mind the slight performance hit)
Jeff
On Nov 16, 2007, at 11:54 PM, Maged Makled wrote:
> Jeff Dean wrote:
>> Here's what I did:
>>
>> gem install --include-dependencies radiant
>> radiant myapp
>> cd myapp
>> [change database.yml]
>> rake db:bootstrap
>> rake radiant:freeze:edge
>> rake radiant:update
>> rake db:migrate
>> [create extension...]
>>
>> Now you'll have a full copy of radiant's source code in your vendor/
>> radiant directory. Now go to
>>
>> vendor/radiant/app/controllers
>>
>> You'll see site_controller.rb (which I mistakenly referred to as
>> SiteController.rb below) - comment out line 2, and sessions will now
>> be enabled for the whole app. If you've previously started your web
>> server, you may have to restart for the changes to take effect.
>>
>> There are much more elegant solutions, I'm sure, but this one worked
>> for me. If you have a problem with edge radiant this might not work.
>> If that happens, let me know.
>
> Hey Jeff,
> Thanks a lot man, I tried it and it works perfectly. Just one
> more question. Do you know how to delete that session from the
> database
> when the session expired. I read some posts and they talked cron jobs
> and things like that but I needed to be handled in my application. Do
> you have a quick solution?
>
> I really appreciate your help man
>
> Maged
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Radiant mailing list
> Post: [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant