How to Manually (Programmatically) login a customer on the store

Hi,

 

For a couple of reasons, I had to create a login page (a PHP script if you will) autonomous from Magento, but in that page, I need to log the user in the Magento store (frontend) as well.

 

I have found dozens of answers to this question online, and most of them theoretically seem to work. But then when I try to access the customer "dashboard", it always redirects to the Magento default Login Page, so I assume that its not really working at all.

 

What I meant by "theoretically", is because I can return the user data (with "->getCustomer()") and if I check if the user is logged in (with "->isLoggedIn()") its returns true.

 

But then ill try to go to the dashboard page ("customer/account") and it redirects to the login page ("customer/account/login").

 

Can someone help me with this problem?

Is it maybe some Magento configuration that Im missing?

Can it be a Cookies/Cache problem?

 

Im using Magento 1.9 by the way.

 

Thanks in advance.