Take the 2-minute tour ×

I have a CakePHP website with its own login system using the Auth component. I would like to know if the following is possible:

A user has logged in and is navigating the website. At one point, he can click a link that opens an external php file. With external I mean that it could be in another folder of the same server, but outside the CakePHP app folders.

The "tricky" thing (for me) is to only show the contents of that php file if the user is logged in (to prevent someone without an account accessing those contents). I can't use Auth there because I'm "outside" Cake... I don't know if maybe using $_SESSION, but I don't know how...

Is this even possible? And yes, the php has to be outside the CakePHP app folder system.

Any ideas?

share|improve this question
var_dump or print_r are very useful php functions. Use them with $_SESSION and you can see everything CakePHP does with it. It's actually interesting to look at. –  Vigrond Dec 23 '11 at 21:24
I had the same question a while ago: stackoverflow.com/questions/6988156/… –  alexBrand Dec 24 '11 at 3:05

2 Answers 2

up vote 4 down vote accepted

Yes you can access the cakephp SESSION outside cakephp folder. try this session variable


if it exists then check for user here

share|improve this answer
thanks for your answer! So basically I just need to check if $_SESSION['Auth']['User'] exists right? For example, with cake, I usually only do $this->Session->check('Auth.User') to know if a user is logged in... would that be the equivalent? –  Albert Dec 23 '11 at 22:05
yeah its right. –  Kashif Khan Dec 23 '11 at 22:16
ok cool! thank you very much! –  Albert Dec 24 '11 at 4:19
@Kashif - its working for me on localhost but not on my shared hosting. It just return an empty session array –  Imran Omar Bukhsh Feb 14 '12 at 9:44

I'll add you also need to set session name to "CAKEPHP" using


just before your external app session_start() otherwise you could not apply Kashif Khan suggested solution :)


share|improve this answer

Your Answer


