cancel
Showing results for 
Search instead for 
Did you mean: 

Customer/Session isLoggedIn Results?.

Customer/Session isLoggedIn Results?.

Hello,

 

I have a problem that's driving me crazy - if someone could help with some insight on this, I'd be super grateful:

 

I have downloadable files in Magento linking to a separate PHP script that generates the downloadable file. I'm trying to only permit access to the file if the user is a) currently logged in, and b) their customer ID matches the ID that was passed to the script.

 

My problem is with (a):

 

require_once('app/Mage.php');
umask(0);
Mage::app('');
$s = Mage::getSingleton('customer/session');

if ($s->isLoggedIn()) {
        echo 'worked';
}
else echo 'failed';

 

The problem is that I can't seem to get reliable results from this. If I'm logged in, it says "failed" most of the time (I try logging out, clearing cache, logging back in, etc. and it still says "failed".) It "worked" the first time I tried it for a few minutes, but after logging out, I can't get it to work anymore. Cookie Path is set to / and Cookie Domain is empty, but both Magento and the script are on the same domain.

 

Any thoughts on where to look/why I can't get reliable results from this?

 

thanks

alexsunny