Problems with navigation after log in

Hi all,

I'm struggling about the following login issue: I have to sites site A and site B. One link "login" on site A navigates me to site B. On site B I enter username and password. If I write a "redirect_to :back" then I'll be forwarded from site B to site B. But I want to redirect after login from Site B to Site A. Does anyone know how to manage that?