How can I redirect after and before login?

Hi all. I’m here again.
I am doing a intensive auto-training right now and I’m getting problems everytime.

So, i want to create a page accessible only to registered members. I already know how to do It but now i’m stucked on redirects.

So let’s start from what I did. I’ve installed the module “member profiles” and after that the “log-in forms”.

I’ve created a new page and put on a column the form i’ve created with the installed module, using the $LoginForm

This is how it looks:

If i log in from that form, everything is ok (and sometimes i get redirected on admin section, sometimes on the same page of login with a / after the url, and this shows me a not syled page…) and shows me i’m logged as and then the button for logout (login as another person).

I would like to create one redirect after the log-in on the new page. i’ve created and inside that page i would like to put a $ that shows the name of the logged person and the log out button (i can leave the “login as another person”…).

After the log-out, i would like to redirect the person on the homepage or on the log in page.

Now when i logout i am redirected to the login form page:

I tried some tutorials that i’ve found on the internet (like insert a public function in the controller page) but still not working.

The problem with silverstripe is that a lot of people doesn’t even know it and most of tutorials are incompleted or old (even 2009 posts…).

Can someone help me? Thank you.

Both the login and logout processes have the BackURL parameter in the URL. That should specify which page you get redirected after the login/logout. The problem is if you go directly to the /Security/login without setting the BackURL, it will just redirect you back to your current page or the fallback URL for the particular controller.

Ok, so I should edit the Login and out handler?