[devise] Writing cookies directly from Warden callback?

1,176 views
Skip to first unread message

Andrew

unread,
May 23, 2010, 5:51:51 PM5/23/10
to Devise
I'd like to be able to access the controller to do:


Warden::Manager.after_set_user do |user,auth,opts|
cookies['foo'] = bar
end

What's the best way to do this?

José Valim

unread,
May 23, 2010, 6:05:33 PM5/23/10
to plataforma...@googlegroups.com
You can have access to cookies in the auth object.

Warden::Manager.after_set_user do |user,auth,opts|
  auth.cookies[key] = value
end

after_set_user is called in several occasions, so you should check warden documentation. Check also lib/devise/hooks in devise source code for more examples.
--
José Valim

Director of Engineering - Plataforma Tecnologia
Know more about us: http://plataformatec.com.br/en/
Reply all
Reply to author
Forward
0 new messages