We have an external application which needs some functions/data from Magento for certain things. I decided to make the login utilise the magento admin accounts and roles. This works and I can login on our application, using the magento admin credentials.
Now I have the following code to check if the user is actually logged in or not:
if(!Mage::getSingleton('admin/session')->isLoggedIn())
{
header('Location: /login.php');
}
This does the trick for the normal pages (returns 1
when logged in). However, if I call a script in the application using AJAX, when it goes over the same check, it returns nothing. I have tried to find why, but so far no success.
EDIT: I have found out that it's not the AJAX request causing it. When I call the script manually, it still returns that it's not logged in. The initial script that checks it is in the root, and the script that doesn't work is in a subfolder.
EDIT 2: I have changed it's folder and even though it goes through the exact same process, it works in the new one. /magedata/script.php has logged in false, /pages/magedata/script.php has logged in true. I am confused.